fn main() {
use std::time::Instant;
let now = Instant::now(); //计算耗时
//=====================================================
let mut i = 0;
while i < 10000 {
// 循环体
i += 1;
println!("值为 : {}", i);
}
//=====================================================
//计算耗时
let duration = now.elapsed();
let s = duration.as_secs();
let mut ms = duration.as_millis();
let mut us = duration.as_micros();
us -= ms * 1000;
ms -= s as u128 * 1000;
println!("耗时:{} s {} ms {} us", s, ms, us);
}
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询