Commit 34f7e6f7 authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

Add LICENCE and README

parent 82d6f165cc3f
Copyright (c) 2020 Raphaël Gomès
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
\ No newline at end of file
# Micro-timer
This crate exposes a simple procedural macro that logs you how much time was spent during each call of the function it wraps.
## Installing
In ``Cargo.toml``:
```toml
[dependencies]
micro-timer = "0.1"
log = "0.4.8"
```
The community-standard ``log`` crate is used for output. In reality, since procedural macros don't have hygiene, you could define `log` as being anything that has the same interface as the `log` crate.
## Usage
```rust
use micro_timer::timed;
/// Expose the `log` crate as `crate::log`.
use log;
#[timed]
fn my_func() {
// code here
}
fn main() {
// Use any standard logger you want.
// In this case, we're using `simple_logger`
simple_logger::init_by_env();
}
```
## Result
```bash
$ RUST_LOG=trace ./my-program
2020-02-27 14:27:01,097 TRACE [my_crate::my_module] Duration of `my_func`: 2.024734ms
```
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment