|
1 |
| -# minstant |
2 |
| -[](https://github.com/tikv/minstant/actions) |
3 |
| -[](https://travis-ci.org/tikv/minstant) |
4 |
| -[](https://docs.rs/minstant/) |
5 |
| -[](https://crates.io/crates/minstant) |
6 |
| -[](https://github.com/tikv/minstant/blob/master/LICENSE) |
| 1 | +# Fastant |
7 | 2 |
|
8 |
| -A drop-in replacement for [`std::time::Instant`](https://doc.rust-lang.org/std/time/struct.Instant.html) that measures time with high performance and high accuracy powered by [TSC](https://en.wikipedia.org/wiki/Time_Stamp_Counter). |
| 3 | +A drop-in replacement for [`std::time::Instant`](https://doc.rust-lang.org/std/time/struct.Instant.html) that measures time with high performance and high accuracy powered by [Time Stamp Counter (TSC)](https://en.wikipedia.org/wiki/Time_Stamp_Counter). |
| 4 | + |
| 5 | +[](https://github.com/fast/fastant/actions) |
| 6 | +[](https://docs.rs/fastant/) |
| 7 | +[](https://crates.io/crates/fastant) |
| 8 | +[](LICENSE) |
9 | 9 |
|
10 | 10 | ## Usage
|
11 | 11 |
|
12 | 12 | ```toml
|
13 | 13 | [dependencies]
|
14 |
| -minstant = "0.1" |
| 14 | +fastant = "0.1" |
15 | 15 | ```
|
16 | 16 |
|
17 | 17 | ```rust
|
18 |
| -let start = minstant::Instant::now(); |
19 |
| - |
20 |
| -// Code snipppet to measure |
21 |
| - |
22 |
| -let duration: std::time::Duration = start.elapsed(); |
| 18 | +fn main() { |
| 19 | + let start = fastant::Instant::now(); |
| 20 | + let duration: std::time::Duration = start.elapsed(); |
| 21 | +} |
23 | 22 | ```
|
24 | 23 |
|
25 |
| - |
26 | 24 | ## Motivation
|
27 | 25 |
|
28 |
| -This library is used by a high performance tracing library [`minitrace-rust`](https://github.com/tikv/minitrace-rust). The main purpose is to use [TSC](https://en.wikipedia.org/wiki/Time_Stamp_Counter) on x86 processors to measure time at high speed without losing much accuracy. |
| 26 | +This library is used by a high performance tracing library [`fastrace`](https://github.com/fast/fastrace). The main purpose is to use [Time Stamp Counter (TSC)](https://en.wikipedia.org/wiki/Time_Stamp_Counter) on x86 processors to measure time at high speed without losing much accuracy. |
29 | 27 |
|
30 | 28 | ## Platform Support
|
31 | 29 |
|
32 |
| -Currently, only the Linux on `x86` or `x86_64` is backed by [TSC](https://en.wikipedia.org/wiki/Time_Stamp_Counter). On other platforms, `minstant` falls back to `std::time`. If TSC is unstable, it will also fall back to `std::time`. |
| 30 | +Currently, only the Linux on `x86` or `x86_64` is backed by Time Stamp Counter (TSC). On other platforms, Fastant falls back to `std::time`. If TSC is unstable, it will also fall back to `std::time`. |
33 | 31 |
|
34 | 32 | If speed is privileged over accuracy when fallback occurs, you can use `fallback-coarse` feature to use coarse time:
|
35 | 33 |
|
36 | 34 | ```toml
|
37 | 35 | [dependencies]
|
38 |
| -minstant = { version = "0.1", features = ["fallback-coarse"] } |
39 |
| -``` |
40 |
| - |
41 |
| -## Benchmark |
42 |
| - |
43 |
| -Benchmark platform is `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz` on CentOS 7. |
44 |
| - |
45 |
| -```sh |
46 |
| -> cargo criterion |
47 |
| - |
48 |
| -Instant::now()/minstant time: [10.449 ns 10.514 ns 10.619 ns] |
49 |
| -Instant::now()/quanta time: [31.467 ns 31.628 ns 31.822 ns] |
50 |
| -Instant::now()/std time: [26.831 ns 26.924 ns 27.016 ns] |
51 |
| -minstant::Anchor::new() time: [46.987 ns 47.243 ns 47.498 ns] |
52 |
| -minstant::Instant::as_unix_nanos() time: [15.287 ns 15.318 ns 15.350 ns] |
| 36 | +fastant = { version = "0.1", features = ["fallback-coarse"] } |
53 | 37 | ```
|
54 |
| - |
55 |
| - |
0 commit comments