Operating System - HP-UX
1830936 Members
1924 Online
110017 Solutions
New Discussion

Re: Need Scripts to stress CPU and Memory

 
SOLVED
Go to solution
Alzhy
Honored Contributor

Need Scripts to stress CPU and Memory

Anyone have a quick set of scripts to max out CPU and Memory Use?

Just want to test some alarm definitions I am creating...

Hakuna Matata.
4 REPLIES 4
Patrick Wallek
Honored Contributor
Solution

Re: Need Scripts to stress CPU and Memory

An easy way to max out CPU ---

# while true
> do
> let i=i+1
> done

If you want to see what the script is doing put an echo in there.

# while true
> do
> let i=i+1
> echo $i
> done

If you have multiple CPUs on the system, run the script multiple times to max out all the CPUs.
Alzhy
Honored Contributor

Re: Need Scripts to stress CPU and Memory

Thanks Patrick.. I actually have these loopers.. any quick Perl/C code that I can use to do malloc's. mmaps etc..?
Hakuna Matata.
A. Clay Stephenson
Acclaimed Contributor

Re: Need Scripts to stress CPU and Memory

Okay here's a 3 minute C program, mem.c. It's written in K&R C so the bundled C compiler will handle it.

Compile like this:

cc mem.c -o mem

Use it like this:

mem 1000
to allocate 1000 1MB chunks

or simply mem
to continue allocating until it fails.
echo ${?} after failure to get errno; it should be ENOMEM 12. It display total memory allocated as it runs.



If it ain't broke, I can fix that.
Alzhy
Honored Contributor

Re: Need Scripts to stress CPU and Memory

Man.. what will I do without you guys!

I know all these from a previous incarnation but my memory cells are starting to die down -- all of 37 years and my memory is already failing! Hopefully we'll all still be alive when the "Brain-Add-On flash memory" will be avilable.. Imagine a 1 Petabyte Brain Module .. he he he!

Thanks A-Clay for the code (just did no have time to review my K&R/C).. Patrick.. thanks for the looper /recursion tricks...

Hakuna Matata.