Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Simulating heavy traffic

by BrowserUk (Patriarch)
on Jul 22, 2004 at 10:20 UTC ( [id://376526]=note: print w/replies, xml ) Need Help??


in reply to Simulating heavy traffic

Here you go a complete stress test suite in 10 26 lines of perl :)

#! perl -slw use strict; use threads; use LWP::Simple; use Time::HiRes qw[sleep]; $!=1; print "Usage $0 [-T=10] [-R=1.0] [-MAX=30] url" unless $ARGV[ 0 ]; ## Number of threads (simultaneuos callers) our $T ||= 10; ## Fire rate in decimal seconds (0.1 once per 1/10 sec/thread) our $R ||= 1.0; ## Seconds to sustain the burst. our $MAX ||= 30; async { getprint( $ARGV[ 0 ] ) while sleep( rand( $R ) ); } for 1 .. $T; sleep $MAX;

WARNING: Be careful who you aim it at!


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://376526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-28 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found