That was an Awesome post from fooler... For these problems, I usually take the lazy route and check www.freshmeat.net and search for "cpu load testing"
3 items come up, the last item looks quite interesting: http://weather.ou.edu/~apw/projects/stress/ --- On Thu, 4/14/11, fooler mail <[email protected]> wrote: From: fooler mail <[email protected]> Subject: Re: [plug] Perl Hog To: "Philippine Linux Users' Group (PLUG) Technical Discussion List" <[email protected]> Date: Thursday, April 14, 2011, 6:42 AM On Wed, Apr 13, 2011 at 10:06 PM, John Homer H Alvero <[email protected]> wrote: > Thanks Fooler, > > I'm gonna need some time to digest the information and probably more > time to perl-port it. :) I'll get back to this list when it's done. I > think it's just right to buy you Tiger Beer next time. hehehehe its ok dude... no worries.. ever since here in plug.. it's been my pleasure helping pluggers with their problem :-> having said that.. i ported the program to perl for your own happiness :-> save it let say to waste.pl and run with the percentage as a parameter... $ ./waste.pl 85 once again... the formula used is .... 1 second = cpu_time * percentage + sleep_time * (1 - percentage) #!/usr/bin/perl -w use strict; use Time::HiRes qw(usleep gettimeofday tv_interval); use constant SAMPLING => 100000000; sub WasteCPU { my ($waste, $percent) = @_; my ($i); for $i (0..$waste) {} usleep((100 - $percent) * 10000); } my ($percent, $waste, $time1, $time2, $elapsed); print "Start to sampling clock speed...\n"; $percent = 100; $waste = SAMPLING; $time1 = [gettimeofday]; WasteCPU($waste, $percent); $time2 = [gettimeofday]; $elapsed = tv_interval($time1, $time2); $percent = $ARGV[0]; $waste = (SAMPLING / $elapsed * $percent / 100); print "Sampling done. Wasting CPU approximately ".$percent." percent...\n"; while (1) { WasteCPU($waste, $percent); } fooler. _________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List http://lists.linux.org.ph/mailman/listinfo/plug Searchable Archives: http://archives.free.net.ph
_________________________________________________ Philippine Linux Users' Group (PLUG) Mailing List http://lists.linux.org.ph/mailman/listinfo/plug Searchable Archives: http://archives.free.net.ph

