Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abrarnitk/exec_time
Time measuring for Rust functions
https://github.com/abrarnitk/exec_time
functionexecutiontime measuretime printexecutiontime rust
Last synced: 5 days ago
JSON representation
Time measuring for Rust functions
- Host: GitHub
- URL: https://github.com/abrarnitk/exec_time
- Owner: AbrarNitk
- License: mit
- Created: 2019-12-08T05:35:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T08:23:25.000Z (almost 2 years ago)
- Last Synced: 2024-12-13T20:54:44.706Z (9 days ago)
- Topics: functionexecutiontime, measuretime, printexecutiontime, rust
- Language: Rust
- Size: 18.6 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Time Measure for Rust Functions
### It will simply print execution time of a function[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Crates.io](https://img.shields.io/crates/v/exec_time)](https://crates.io/crates/exec_time)
[![Build Status](https://travis-ci.org/AbrarNitk/exec_time.svg?branch=master)](https://travis-ci.org/AbrarNitk/exec_time)#### Usage
```toml
[dependencies]
exec_time = "0.1.4"
```## Examples
In print log, it is printing `Time ::::: mills`#### Example 1
It will always print.```rust
#[macro_use]
extern crate exec_time;#[exec_time]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}fn main() {
login()
}
``````text
Time login: 102 mills
```#### Example 2
It will print only in debug mode.```rust
#[macro_use]
extern crate exec_time;#[exec_time(print = "debug")]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}fn main() {
login()
}
``````text
Time login: 102 mills
```#### Example 3
It will never print.```rust
#[macro_use]
extern crate exec_time;#[exec_time(print = "never")]
fn login() {
std::thread::sleep(std::time::Duration::from_millis(100));
}fn main() {
login()
}
``````text
```#### Example 4
It will print, prefix and suffix with function name.```rust
#[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()
}
``````text
Time user/lib::login::route: 102 mills
```### Note Point
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.