#计时器 #计时 #拆分 #清除 #原始 #重写 #时间

stopwatch2

一个用于计时的计时器库。对原始计时器crate的重写和简化。

1 个稳定版本

2.0.0 2021年4月30日

#369日期和时间

Download history 166/week @ 2024-03-13 256/week @ 2024-03-20 205/week @ 2024-03-27 251/week @ 2024-04-03 259/week @ 2024-04-10 164/week @ 2024-04-17 185/week @ 2024-04-24 156/week @ 2024-05-01 142/week @ 2024-05-08 134/week @ 2024-05-15 136/week @ 2024-05-22 173/week @ 2024-05-29 117/week @ 2024-06-05 178/week @ 2024-06-12 169/week @ 2024-06-19 245/week @ 2024-06-26

724 每月下载量
用于 6 个crate(5 个直接使用)

MIT 许可证

10KB
159

Stopwatch2

Stopwatch V2

支持开源开发者!♥️
Become a patron

阅读 文档

此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

无运行时依赖