CPU Watcher

CPU watcher is the tool to measure CPU performance by running dummy payload.

It's obvious that cpu performance on physical machine without any payload is must be near equal in any time. However in real life some background services or daemons may be running. CPU watcher is measure CPU performance within some time period and you can analyse and compare gathered data to determine a influence of background services or daemons to CPU performance.

In virtual environment physical machine cpu performance is shared with some virtual machines or containers. If CPU consumption on one virtual machine is high other virtual machines can have reducing of CPU performance.

You can compare data received by CPU watcher in virtual machine before, in time & after running high payload on other virtual machine to determine influence of cpu consumption on virtual machines.

If you run cpu watcher in physical machine and in virtual machine hosted on this physical machine you can receive a difference of CPU performance in both contexts. Changing contexts can take some CPU performance.

Also you can compare data received by CPU watcher in many environments to make decision which is better to your site or application.

WARNING: CPU watcher is set of PHP scripts therefore the PHP-interpreter version can influence to results of measurements. If you wish to take objective data PHP-interpreter versions should be same or loop script is can be ported to binary.

How CPU performance is measured?

CPU watcher is measure the time needed to run some quantity of cycles.

CPU watcher can be running in multiple threads to define performance of all cpus & cores.

How to use cpu watcher?

It's simple. Just install PHP in your environment and run start script.

./start <number of threads>

When cpu watcher is running it write logs of performance of each thread in proper log-file in logs directory.

Warning: Log-files is overwritten when cpu_watcher is started. Don't forget to copy it if needed.

To stop running of cpu watcher just run stop script. It will stop all cpu watcher threads automaticaly.


Also you can stop all cpu watcher threads manualy by calling KILL command against all PIDs stored in pids-files in pids directory:

kill <PID>

If you wish to run cpu watcher in strict time period you can use next command

./start && sleep <time period in seconds> && ./stop

System requrements

  • POSIX-compatible environment
  • PHP
  • Console