Difference between revisions of "ZhoubaWiki:Bc-cpu-benchl"

From ZhoubaWiki
Jump to navigation Jump to search
(Created page with "== 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 spe...")
 
 
Line 2: Line 2:
  
 
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:
 
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:
 
+
<pre>
 
$ time echo "scale=5000; a(1)*4" | bc -l
 
$ time echo "scale=5000; a(1)*4" | bc -l
 
+
</pre>
 
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:
 
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:
 
+
<pre>
 
#!/bin/bash
 
#!/bin/bash
 
echo "scale=$1; a(1)*4" | bc -l
 
echo "scale=$1; a(1)*4" | bc -l
 
+
</pre>
 
The first argument is number of digits to calculate. Now we can run in parallel (4 times) this way
 
The first argument is number of digits to calculate. Now we can run in parallel (4 times) this way
 
+
<pre>
 
$ time parallel ./b.sh ::: 2000 2000 2000 2000
 
$ time parallel ./b.sh ::: 2000 2000 2000 2000
 
+
</pre>
 
We can determine the number of cores with this command:
 
We can determine the number of cores with this command:
 
+
<pre>
 
$ cat /proc/cpuinfo  | grep processor | wc -l
 
$ cat /proc/cpuinfo  | grep processor | wc -l
 
4
 
4
 
+
</pre>
 
If your cpu supports hyper threading - this will give you the number of logical cores, not only the physical ones
 
If your cpu supports hyper threading - this will give you the number of logical cores, not only the physical ones

Latest revision as of 18:17, 19 September 2022

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:

#!/bin/bash
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
4

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