Skip to content

Instantly share code, notes, and snippets.

@zachallett
Created December 3, 2013 21:20
Show Gist options
  • Select an option

  • Save zachallett/7777682 to your computer and use it in GitHub Desktop.

Select an option

Save zachallett/7777682 to your computer and use it in GitHub Desktop.
Load testing scripts
#!/usr/bin/perl
use strict;
use warnings;
use threads;
my $NUM_THREADS = 8;
sub do_work {
while() {
my $a = rand + rand;
}
}
for(1 .. $NUM_THREADS) {
my $thr = threads->create(\&do_work);
}
for my $thr (threads->list()) {
$thr->join();
}
exit;
#! /usr/bin/env ruby
# set equal to number of CPU cores
NUMBER_OF_THREADS = 4
def load_test
while(true) do
rand(0..10000) + rand(0..10000)
end
end
(1..NUMBER_OF_THREADS).each do |p|
fork do
puts "PID -> #{Process.pid}"
load_test
end
end
# Process.waitall waits for all children to return an exit status
Process.waitall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment