Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script that benchmarks CPU performance giving a result that can be used to compare against other servers?

Any help with the below will be very much appreciated:

  • This script should not overrun the box to the extent all the resources are used.
  • As an example, the script could run an integer equation that works out response time as a measurement of performance.
  • My theory is to attach it to a monitoring system to periodically run the test across multiple servers.

Any ideas?

like image 991
Swordfish Avatar asked Oct 19 '25 13:10

Swordfish


1 Answers

Performance testing isn't nearly as simplistic as that. All you test doing a particular operation is how fast a system completes that particular operation on that particular day.

CPUs are fast now, and they're rarely the bottleneck any more.

So this comes back to the question - what are you trying to accomplish? If you really want a relative measure of CPU speed, then you could try something like using the system utility time.

Something like:

time ssh-keygen -b 8192 -f /tmp/test_ssh -N '' -q

Following on from comments: This will prompt you to overwrite. You can always delete /tmp/test_ssh. (I wouldn't suggest using a variable filename, as that'll be erratic)

As an alternative - if it's installed - then I'd suggest using openssl.

E.g.

time openssl genrsa 4096

Time returns 3 numbers by default:

  • 'real' - elapsed wallclock time.
  • 'user' - cpu-seconds spent running the user elements of the task.
  • 'sys' - cpu-seconds spent running system stuff.

For this task - I'm not entirely sure how the metrics pan out - I'm not 100% sure if VMware 'fakes' the CPU time in the virtualisation layer. Real and user should (for this operation) be pretty similar, normally.

I've just tested this on a few of my VMs, and have had a fairly pronounced amount of 'jitter' in the results. But then, this might be what you're actually testing for. Bear in mind though - CPU isn't the only contended resource on a VM. Memory/disk/network are also shared.

like image 145
Sobrique Avatar answered Oct 22 '25 06:10

Sobrique