Giter Club home page Giter Club logo

minstant's Introduction

minstant

Actions Status Build Status Documentation Crates.io LICENSE

A drop-in replacement for std::time::Instant that measures time with high performance and high accuracy powered by TSC.

Usage

[dependencies]
minstant = "0.1"
let start = minstant::Instant::now();

// Code snipppet to measure

let duration: std::time::Duration = start.elapsed();

Motivation

This library is used by a high performance tracing library minitrace-rust. The main purpose is to use TSC on x86 processors to measure time at high speed without losing much accuracy.

Platform Support

Currently, only the Linux on x86 or x86_64 is backed by TSC. On other platforms, minstant falls back to coarse time. If TSC is unstable, it will also fall back to coarse time.

Benchmark

Benchmark platform is Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz on CentOS 7.

> cargo criterion

Instant::now()/minstant             time:   [10.449 ns 10.514 ns 10.619 ns]
Instant::now()/quanta               time:   [31.467 ns 31.628 ns 31.822 ns]
Instant::now()/std                  time:   [26.831 ns 26.924 ns 27.016 ns]
minstant::Anchor::new()             time:   [46.987 ns 47.243 ns 47.498 ns]
minstant::Instant::as_unix_nanos()  time:   [15.287 ns 15.318 ns 15.350 ns]

Benchmark

minstant's People

Contributors

zhongzc avatar andylokandy avatar a-manning avatar bugenzhao avatar dotansimha avatar xuanwo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.