Crates.io | exec_time |
lib.rs | exec_time |
version | 0.1.4 |
source | src |
created_at | 2019-12-08 12:13:57.116066 |
updated_at | 2019-12-10 01:38:30.568407 |
description | Print execution time of a function |
homepage | |
repository | https://github.com/AbrarNitk/exec_time |
max_upload_size | |
id | 187272 |
size | 3,857 |
[dependencies]
exec_time = "0.1.4"
In print log, it is printing Time <prefix>::<function_name>::<suffix>: <execution time> mills
It will always print.
#[macro_use]
extern crate exec_time;
#[exec_time]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
fn main() {
login()
}
Time login: 102 mills
It will print only in debug mode.
#[macro_use]
extern crate exec_time;
#[exec_time(print = "debug")]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
fn main() {
login()
}
Time login: 102 mills
It will never print.
#[macro_use]
extern crate exec_time;
#[exec_time(print = "never")]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
fn main() {
login()
}
It will print, prefix and suffix with function name.
#[macro_use]
extern crate exec_time;
#[exec_time(print = "always", prefix = "user/lib", suffix="route")]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
fn main() {
login()
}
Time user/lib::login::route: 102 mills
Here print
, prefix
and suffix
all are optional field. Default value of print is always
.
print
may be always
(by default), debug
, never
. If the value is always
it will print always.
If value is debug
, It will print only in debug mode else, It will never print.