(tye)Re: one-liner hogs
by tye (Sage) on Feb 01, 2001 at 04:16 UTC
|
Memory: perl -e 'push @_,"x"x1024 while 1'
CPU: perl -e '$_++ while 1'
Floats: perl -e '$_= ($_*76543+23456789) % 1234567891 while 1'
Procs: perl -e 'fork() while 1'
Procs2: perl -e '$_=2;while(1){sleep($_+=fork?$_:1)}'
Reads: perl -MFile::Find -e'find(sub{@ARGV=$_;1while<>},"/")while 1'
MemUse: perl -e '$_="ab"x(8*1024*1024);tr/ab/ba/ while 1'
Swap: perl -e 'while(1){push @_,"x";for(@_){$_="x$_"}}'
To double the load, prepend "fork;" to the line. For example, four-times as much "read" load can be (attempted to be) generated via:
perl -MFile::Find -e 'fork;fork;find(sub{@ARGV=$_;1while<>},"/")while
+1'
My favorite is "Procs2", which is the only one I tested; most of these you don't want to test when anyone else is using the computer. (:
-
tye
(but my friends call me "Tye") | [reply] [Watch: Dir/Any] [d/l] [select] |
|
"A man's maturity -- consists in having found again the
seriousness one had as a child, at play." --Nietzsche
| [reply] [Watch: Dir/Any] [d/l] |
|
Sorry. Just saw your signature line and noticed it was from Nietzsche. I saw a pretty funny bumper sticker the other day that read:
God is dead. - Nietzsche.
Nietzsche is dead. - God.
| [reply] [Watch: Dir/Any] |
|
Nice Tye, but I honestly can't see myself memorising your floats one :)
| [reply] [Watch: Dir/Any] |
|
Floats: perl -e '$_= ($_*36217+41081) % 492391271 while 1'
to Floats: perl -e '$_= ($_*76543+23456789) % 1234567891 while 1'
Now that is much easier to remember. Thanks!
-
tye
(but my friends call me "Tye") | [reply] [Watch: Dir/Any] [d/l] [select] |
|
CPU: perl -e '{redo}'
| [reply] [Watch: Dir/Any] [d/l] |
Re: one-liner hogs
by Trinary (Pilgrim) on Feb 01, 2001 at 03:37 UTC
|
perl -e 'while (++$i) { $foo[$i] = $i; }'
That'll chew memory like mad, and soon bomb out. CPU usage minimal.
of course, you can make it use CPU...
perl -e 'fork; fork; while (++$i) { $c .= crypt($i,$i); $c = substr($c
+,4,128); }
Ctrl-C kills all children, no root required! Load should fly up to around 4, give it a minute or two. To add mem usage, change the substr length.
Fun request! Trinary | [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] [d/l] |
Re: one-liner hogs
by Kanji (Parson) on Feb 01, 2001 at 03:32 UTC
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] [d/l] |
|
I guy in my OS class
ran something similar to that
and logged out of the main CS server without killing
it. A short time later, the whole lab wondered why
they couldn't save their assignments . . .
Needless to say he had a lot of explaining to do with
the IT staff. And that was the LAST time the OS classes
used the main CS server!
Jeff
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)
| [reply] [Watch: Dir/Any] |
|
Actually, there's a slight problem with the old fork() bomb: most OSes only allow so many running processes and there are a few that go so far as to limit the number of running processes an individual user can have, so you could, possibly, run out of processes before you run out of memory. ~Cybercosis
Update: Actually, it is somewhat required for an OS to limit the number of possible processes, since you can only hold so many TSS templates to be moved into the TSS register in memory. Well, at least with i86 processors. =-)
| [reply] [Watch: Dir/Any] [d/l] |
Re: one-liner hogs
by arturo (Vicar) on Feb 01, 2001 at 03:24 UTC
|
Well, eating memory's easy enough to do, figuring out how to do it efficiently (is that an oxymoron? No, we're talking about time efficiency) is another ...
perl -e 'while (1) { push @stuff, "all work and no play makes arturo a
+ dull boy" }'
What do ya wanna test, memory hoggage, CPU hoggage, filesystem hoggage?
Philosophy can be made out of anything. Or less -- Jerry A. Fodor | [reply] [Watch: Dir/Any] [d/l] |
|
"A man's maturity -- consists in having found again the
seriousness one had as a child, at play." --Nietzsche
| [reply] [Watch: Dir/Any] [d/l] |
Re: one-liner hogs
by extremely (Priest) on Feb 01, 2001 at 03:59 UTC
|
How about this for processor churn?
perl -e '$_="abcd"x100000;while(1){y/abcd/bcda/}'
perl -e '@_=0..1000000;while(1){foreach(@_){++$_,--$_}}'
perl -e '@_=0..100000;while(1){foreach(@_){$a=$_/++$_;--$_}}'
The first exercises about about 8MB of memory fairly heavily.
The second beats up 64MB of memory with light mathops.
The third eats 9MB with a heavier math op.
Obviously you can tweak how much memory is eaten with
monster number in there... HTH.
--
$you = new YOU;
honk() if $you->love(perl) | [reply] [Watch: Dir/Any] [d/l] [select] |
Re: one-liner hogs
by jepri (Parson) on Feb 01, 2001 at 10:24 UTC
|
Probably a bit late now, but
perl -e'print "a".."ZZZZZZZZZZZZ"'
will drop a Linux box most times. It's deceptive too. You get just enough time to say "That's stupid, it didn't work at all" and then it bites... :)
____________________
Jeremy
I didn't believe in evil until I dated it. | [reply] [Watch: Dir/Any] [d/l] |
|
perl -e"@_=a..z.~0"
-
tye
(but my friends call me "Tye") | [reply] [Watch: Dir/Any] [d/l] |
|
I like it, it maxed out both my CPU and memory more than some of the others. Oops.. wasn't I meant to try? =)
| [reply] [Watch: Dir/Any] |
**Palindromic** one-liner hog :)
by MeowChow (Vicar) on Feb 01, 2001 at 12:36 UTC
|
lave,,,,s,,reverse;eval;lave;esrever,,s,,,,eval
Ok, so the reverse doesn't really have to be in there, but i think it's cheating if any part of the palindromic code isn't actually executed :-)
MeowChow
print $/='"',(`$^X\144oc $^X\146aq1`)[-2] | [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] |
Re: one-liner hogs
by jynx (Priest) on Feb 01, 2001 at 04:01 UTC
|
And how about one for disk hoggage:
perl -e '(open T "/tmp/f.$t" and print T "disk\n"x256; close T) while
+(++$t);'
That should work. If not a little variation should be close enough. There are probably more efficient ways to do this, but that's the first thing off the top of my head...
HTH,
jynx | [reply] [Watch: Dir/Any] [d/l] |
|
For disc overflows:
not perl, but works:
cat /dev/zero > /tmp/.#overflow#
Of course, could also be
perl -e 'open T,">/tmp/.#overflow#";open F,"</dev/zero";while(<F>){pri
+nt T;};'
Or the 'smarter'(?) way to completely overflow a machine (but probably only as root):
perl -e 'open M,"/sbin/mount|grep -v':'";while(<M>){($m)=split($_);if(
+fork){open Z,"</dev/zero";open F,">$m/.#overflow#";while(<Z>){print F
+}}};'
But that's WAY too much to memorize, da? | [reply] [Watch: Dir/Any] [d/l] [select] |
|
open(ZERO,"</dev/zero") or die $!;
my $x= <ZERO>;
I think I'll let someone else explain what that does so
people have a little time to think about it. (:
-
tye
(but my friends call me "Tye") | [reply] [Watch: Dir/Any] [d/l] |
|
Re: one-liner hogs
by quidity (Pilgrim) on Feb 01, 2001 at 17:25 UTC
|
You could always eat all your file descriptors, not quite a one liner, but try running a web server at the same time as this little sucker. This is why clever persons use per process limitations.
#!/usr/bin/perl
for (;;) {
my $fh; eval {open($fh, "foo.pl")};
last if $!;
push @foo, $fh;
}
print "all out $!\n";
sleep(1000);
| [reply] [Watch: Dir/Any] [d/l] |
Re: one-liner hogs
by ftforger (Sexton) on Feb 01, 2001 at 21:23 UTC
|
jptxs: Your suggestion of "one liners" seems suspect to
me. Why would these be better than having a perl programmer
write several of these into a small program. Your engineers
run one program and select the type load they want to
test, or demo. If done properly you could combine several
of these to run at the same time, while keeping the ability
to kill it at will. (That would be a good idea in any
event). | [reply] [Watch: Dir/Any] |
|
"A man's maturity -- consists in having found again the
seriousness one had as a child, at play." --Nietzsche
| [reply] [Watch: Dir/Any] [d/l] |
|
I realized what you were getting at originally, but I would
suggest putting this kind of a test/demo suite together on
the same disk you give the sales people. It can carry the
company logo etc. Its NOT identical to the disk you sell,
of course the only real difference is the test/demo suite.
Another option would be to create a specific sales/demo disk
with the full company logo on it.
| [reply] [Watch: Dir/Any] |
Re: one-liner hogs
by unimatrix (Initiate) on Feb 01, 2001 at 15:01 UTC
|
| [reply] [Watch: Dir/Any] |
Re: one-liner hogs
by Ranna (Acolyte) on Oct 22, 2001 at 11:02 UTC
|
Windows is mean, it runs all of the memory-hog one-liners and spits out a message saying 'Out of memory!' without dying fantastically like I've come to expect from it (such as when VMWare took over my computer...) | [reply] [Watch: Dir/Any] |
Re: one-liner hogs
by letual (Initiate) on Feb 02, 2001 at 02:26 UTC
|
| [reply] [Watch: Dir/Any] [d/l] |