I'm working on a small function, that gives my users a picture of how occupied the CPU is.
I'm using cat /proc/loadavg
, wich returns the wellknown 3 numbers.
My problem is that the CPU doesn't do anything right now, while I'm developing.
Is there a good way to generate som load on the CPU, I was thinking something like makecpudosomething 30
, for a load of 0.3 or similar. Does an application like this exist?
Also, are there any way to eat up RAM in a controlled fashion?
Thanks
Michael
The simplest way I have found to load the RAM (and SWAP) is by using Perl:
Use "memtester" to do your memory regression tests in Linux.
you can stress utility, as it is a workload generator tool designed to subject your system to a configurable measure of CPU, memory, I/O and disk stress.
To run 1 vm stressor using 1GB of virtual memory for 60s, enter:
stress --vm 1 --vm-bytes 1G --vm-keep -t 60s
I took this program and modify the line: mem = 1024*1024*512; //512 mb to say this: mem = 1*1024*1024*1024; //1 GB and compile it.
$ gcc iss_mem.c -o iss_mem
And write a bash wrapper around the compiled version of the C program above. It helps me generate a lot of memory load in my server.
1G memory
Is a simple benchmarking command that will give your cpu a rousting, post your times :D