From ZhoubaWiki
Jump to navigation Jump to search

Bc as CPU benchmark for multicore cpu

Referring to this http://tuxshell.blogspot.com/2009/08/bc-as-cpu-benchmark.html post, I figured out the simple way how to test speed of multicore cpu system or multi cpu system. This command:

$ time echo "scale=5000; a(1)*4" | bc -l

will only be executed on one CPU core. However we can use GNU parallel command to execute it many times on multicore cpu. First we create benchmark script b.sh as follows:

echo "scale=$1; a(1)*4" | bc -l

The first argument is number of digits to calculate. Now we can run in parallel (4 times) this way

$ time parallel ./b.sh ::: 2000 2000 2000 2000

We can determine the number of cores with this command:

$ cat /proc/cpuinfo  | grep processor | wc -l

If your cpu supports hyper threading - this will give you the number of logical cores, not only the physical ones