Wednesday, February 18, 2015

Bc as CPU benchmark for multicore cpu

Referring to this 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  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 ./ ::: 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

1 comment:

  1. Raspberry Pi 3 - Raspbian-lite 4.1.19-v7+
    4 core ARM Cortext-A53 1.2GHz 1GB (128MB for display)

    Single core 2000 result:
    real 0m8.045s
    user 0m8.030s
    sys 0m0.010s

    4 core 2000 result:
    real 0m8.761s
    user 0m32.120s
    sys 0m0.080s