How to measure the speed/performance of a program

benchmark

Recently, I was looking at the performance impact of tools such as strace. For instance, this blog post uses the default metrics given by dd.

I wanted to do some measurements myself but with other programs. Is there a tool that measures the speed of execution of an arbitrary program?

Best Answer

Read also time(7) (assuming a Linux system). You can not only use time(1) but also some time functions (e.g. clock(3), clock_gettime(2), etc...) inside the program.

See also this.

Look also into gprof(1), perf(1), oprofile(1). You may want to invoke the GCC compiler specifically (e.g. gcc -pg for gprof) for profiling and/or benchmarking, which has some overhead.

Related Question