1 个稳定版本
2.0.0 | 2021年4月30日 |
---|
#369 在 日期和时间
724 每月下载量
用于 6 个crate(5 个直接使用)
10KB
159 行
Stopwatch V2
阅读 文档。
此crate是ellisonch的工作的简化版本。
特性
- 添加了一个简单的计时器。
- 可以使用多个拆分,甚至可以在它们之间暂停!
- 使用简单,文档清晰。
使用方法
将以下内容添加到您的Cargo.toml文件中
stopwatch2 = "*"
使用计时器如下
use stopwatch2::*;
fn main() {
let mut s = Stopwatch::default();
s.start(); // Starts the stopwatch.
s.start(); // Creates a new time span, which are commonly called "splits".
s.stop(); // Stops the stopwatch.
println!("{}", s); // Prints the total time.
println!("{:?}", s); // Prints the different time spans as debug information.
let total_time = s.elapsed(); // returns the total time as a Duration.
for span in &s.spans {
// Prints all contained time spans.
println!("{:?} -> {:?}", span.start, span.stop);
}
s.spans.clear(); // Reset the stopwatch.
println!("{}", s); // Prints the total time.
println!("{:?}", s); // Prints the different time spans as debug information.
}
维护者信息
- 维护者:Jojolepro
- 联系方式:jojolepro [at] jojolepro [dot] com
- 网站: jojolepro.com
- Patreon: patreon