{"id":13632556,"url":"https://github.com/tikv/minstant","last_synced_at":"2025-04-12T19:42:34.652Z","repository":{"id":38056106,"uuid":"278098612","full_name":"tikv/minstant","owner":"tikv","description":"Performant time measuring in Rust","archived":false,"fork":false,"pushed_at":"2024-03-18T22:04:36.000Z","size":231,"stargazers_count":188,"open_issues_count":2,"forks_count":21,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-03T23:09:40.940Z","etag":null,"topics":["high-performance","high-performance-computing","timing","tsc"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tikv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-08T13:35:35.000Z","updated_at":"2025-03-24T09:16:34.000Z","dependencies_parsed_at":"2024-03-01T06:43:42.816Z","dependency_job_id":"a51e45ca-86fc-4712-964e-ca69c7d07322","html_url":"https://github.com/tikv/minstant","commit_stats":{"total_commits":25,"total_committers":4,"mean_commits":6.25,"dds":0.24,"last_synced_commit":"27c9ec5ec90b5b67113a748a4defee0d2519518c"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fminstant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fminstant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fminstant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fminstant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tikv","download_url":"https://codeload.github.com/tikv/minstant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625350,"owners_count":21135511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["high-performance","high-performance-computing","timing","tsc"],"created_at":"2024-08-01T22:03:06.796Z","updated_at":"2025-04-12T19:42:34.623Z","avatar_url":"https://github.com/tikv.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# minstant\n[![Actions Status](https://github.com/tikv/minstant/workflows/CI/badge.svg)](https://github.com/tikv/minstant/actions)\n[![Build Status](https://travis-ci.org/tikv/minstant.svg?branch=master)](https://travis-ci.org/tikv/minstant)\n[![Documentation](https://docs.rs/minstant/badge.svg)](https://docs.rs/minstant/)\n[![Crates.io](https://img.shields.io/crates/v/minstant.svg)](https://crates.io/crates/minstant)\n[![LICENSE](https://img.shields.io/github/license/tikv/minstant.svg)](https://github.com/tikv/minstant/blob/master/LICENSE)\n\nA 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).\n\n## Usage\n\n```toml\n[dependencies]\nminstant = \"0.1\"\n```\n\n```rust\nlet start = minstant::Instant::now();\n\n// Code snipppet to measure\n\nlet duration: std::time::Duration = start.elapsed();\n```\n\n\n## Motivation\n\nThis 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.\n\n## Platform Support\n\nCurrently, 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`.\n\nIf speed is privileged over accuracy when fallback occurs, you can use `fallback-coarse` feature to use coarse time:\n\n```toml\n[dependencies]\nminstant = { version = \"0.1\", features = [\"fallback-coarse\"] }\n```\n\n## Benchmark\n\nBenchmark platform is `Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz` on CentOS 7.\n\n```sh\n\u003e cargo criterion\n\nInstant::now()/minstant             time:   [10.449 ns 10.514 ns 10.619 ns]\nInstant::now()/quanta               time:   [31.467 ns 31.628 ns 31.822 ns]\nInstant::now()/std                  time:   [26.831 ns 26.924 ns 27.016 ns]\nminstant::Anchor::new()             time:   [46.987 ns 47.243 ns 47.498 ns]\nminstant::Instant::as_unix_nanos()  time:   [15.287 ns 15.318 ns 15.350 ns]\n```\n\n![Benchmark](benchmark.jpeg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftikv%2Fminstant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftikv%2Fminstant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftikv%2Fminstant/lists"}