GithubHelp home page GithubHelp logo

xu-cheng / howlong Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 4.0 71 KB

:watch: Measure how long it takes for a program to execute in different clocks

Home Page: https://docs.rs/howlong

License: Apache License 2.0

Rust 99.57% C 0.43%
rust timer-clock profiling-library

howlong's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

howlong's Issues

SystemClock time vs. ProcessCPUClock's real time

Thank you for this library!

A thing that confuses me is the difference between

let wall_clock = howlong::HighResolutionClock::now();
let elapsed_wall_time = howlong::HighResolutionClock::now() - wall_clock;

println!(elapsed_wall_time);

and

let cpu_clock = howlong::ProcessCPUClock::now();
let elapsed_cpu_time = howlong::ProcessCPUClock::now() - cpu_clock;

println!(elapsed_cpu_time.real);

Colloquially, "real" time is "wall clock" time, which seems to correspond to SystemClock (which is aliased by HighResolutionClock) per this crate's docs and in the parlance of the Boost library's docs with their system_clock.

But "CPU time" is colloquially "process user (out-of-kernel) time + process system (in-kernel) time", which would seem to correspond to:

elapsed_cpu_time.user.as_secs() + elapsed_cpu_time.system.as_secs()

But then what's elapsed_cpu_time.real? Boost docs corroborate this terminology ("timing information is broken down into real (wall clock) time, CPU time spent by the user, and CPU time spent by the operating system servicing user requests.") but don't seem to explain what the difference is between their process_real_cpu_clock and system_clock.

Some clarification in the docs would be great!

Doesn't compile with resolver="2" on Windows

Steps to reproduce:

  1. Create a new project with the following Cargo.toml:
    [package]
    name = "example"
    version = "0.1.0"
    edition = "2018"
    resolver = "2"
    
    [dependencies]
    howlong = "0.1"
    
  2. Run cargo check

I get the following error:

error[E0432]: unresolved imports `winapi::um::errhandlingapi`, `winapi::um::processthreadsapi`
 --> C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\howlong-0.1.6\src\clock\win.rs:6:5
  |
6 |     errhandlingapi::GetLastError,
  |     ^^^^^^^^^^^^^^ could not find `errhandlingapi` in `um`
7 |     processthreadsapi::{GetCurrentProcess, GetCurrentThread, GetProcessTimes, GetThreadTimes},
  |     ^^^^^^^^^^^^^^^^^ could not find `processthreadsapi` in `um`

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.