5个版本
0.2.3 | 2022年2月23日 |
---|---|
0.2.2 | 2019年10月12日 |
0.2.1 | 2017年9月3日 |
0.2.0 | 2017年9月2日 |
0.1.0 | 2017年9月2日 |
#333 在 测试 类别中
1,628 每月下载量
在 22 个crate中(21 个直接) 使用
5KB
time_test
time_test
是一个超级简单的crate,你可以用它轻松获取测试运行所需的时间。使用它很简单(见 example/
中的示例用例)
#[macro_use]
extern crate time_test;
#[cfg(test)]
mod tests {
#[test]
fn my_test() {
time_test!();
println!("hello world");
{
time_test!("sub-assert 1");
assert!(true);
}
assert_eq!(1, 1);
}
}
将宏 time_test!()
添加到测试中想要测量运行时间的行,测试结果行将显示测试所需的时间
$ # 1 test thread so that the output is not garbled.
$ cargo test -- --test-threads=1
Finished dev [unoptimized + debuginfo] target(s) in 0.78 secs
Running target/debug/deps/example-a84426a5de188514
running 1 test
test example::tests::my_test ... (sub-assert 1 took PT0.000002421S) (took PT0.000004178S) ok
lib.rs
:
time_test
是一个超级简单的crate,你可以用它轻松获取测试运行所需的时间。使用它很简单(见 example/
中的示例用例)
#[macro_use] extern crate time_test;
#[cfg(test)]
mod tests {
#[test]
fn my_test() {
time_test!();
println!("hello world");
{
time_test!("sub-assert 1");
assert!(true);
}
assert_eq!(1, 1);
}
}
将宏 time_test!()
添加到测试中想要测量运行时间的行,测试结果行将显示测试所需的时间
$ # 1 test thread so that the output is not garbled.
$ cargo test -- --test-threads=1
Finished dev [unoptimized + debuginfo] target(s) in 0.78 secs
Running target/debug/deps/example-a84426a5de188514
running 1 test
test example::tests::my_test ... (sub-assert 1 took PT0.000002421S) (took PT0.000004178S) ok
依赖项
~0.6–1MB
~15K SLoC