How is it possible to benchmark programs in Rust? For example, how would I get execution time of program in seconds?
相关问题
- Share Arc between closures
- How to account for clock offsets in a distributed
- Function references: expected bound lifetime param
- Pattern matching on slices
- How can I iteratively call Sha256::digest, passing
相关文章
- How can I convert a f64 to f32 and get the closest
- What is a good way of cleaning up after a unit tes
- How can I unpack (destructure) elements from a vec
- How to import macros in Rust?
- Get POSIX epoch as system_clock::time_point
- How to get struct field names in Rust? [duplicate]
- Confusion between [T] and &[T]
- How do I initialize an opaque C struct when using
I created a small crate for this (measure_time), which logs or prints the time until end of scope.
A quick way to find out the execution time of a program, regardless of implementation language, is to run
time prog
on the command line. For example:The most interesting measurement is usually
user
, which measures the actual amount of work done by the program, regardless of what's going on in the system (sleep
is a pretty boring program to benchmark).real
measures the actual time that elapsed, andsys
measures the amount of work done by the OS on behalf of the program.