xu-cheng / howlong Goto Github PK
View Code? Open in Web Editor NEW: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
: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
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!
Steps to reproduce:
Cargo.toml
:
[package]
name = "example"
version = "0.1.0"
edition = "2018"
resolver = "2"
[dependencies]
howlong = "0.1"
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`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.