Benchmarking programs in Rust

前端 未结 8 1178
礼貌的吻别
礼貌的吻别 2020-12-07 23:50

How is it possible to benchmark programs in Rust? For example, how would I get execution time of program in seconds?

8条回答
  •  离开以前
    2020-12-08 00:36

    I created a small crate for this (measure_time), which logs or prints the time until end of scope.

    #[macro_use]
    extern crate measure_time;
    fn main() {
        print_time!("measure function");
        do_stuff();
    }
    

提交回复
热议问题