diff options
| author | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:23:25 -0500 |
|---|---|---|
| committer | Jules Laplace <carbon@melanarchy.org> | 2013-08-02 17:23:25 -0500 |
| commit | e76b691e78e273226cba9284cb8cd22a423319ed (patch) | |
| tree | a58d22f69869fe2bf3885f81bdda4952f87ff6d7 /bucky2/t/ping.pl | |
| parent | 753f60c7d4769fa72d3b910e491f37db6f130898 (diff) | |
bucky2
Diffstat (limited to 'bucky2/t/ping.pl')
| -rwxr-xr-x | bucky2/t/ping.pl | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/bucky2/t/ping.pl b/bucky2/t/ping.pl new file mode 100755 index 0000000..96f50f6 --- /dev/null +++ b/bucky2/t/ping.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl +use lib "../lib"; +use Bucky; +tie my $timer, 'Time::Stopwatch'; + +print_timer($timer, "Initialized"); +my $i = 0; +my $old_t = 0; +while (1) + { + $i++; + my $bucky = new Bucky; + my $threads = $bucky->db->select("comments","id > ".int rand 4598); + if ($timer > $old_t) + { + $old_t++; + print_timer($timer, "$i done, ".(sprintf("%.02f",$i/$timer))."/s"); + } + } + + +sub print_timer + { print sprintf "%3.2f s %s\n", shift, shift; } + +################################################3 + +package Time::Stopwatch; +my $VERSION = '1.00'; + +use strict; +use constant HIRES => eval { local $SIG{__DIE__}; require Time::HiRes }; + +sub TIESCALAR { + my $pkg = shift; + my $time = (HIRES ? Time::HiRes::time() : time()) - (@_ ? shift() : 0); + bless \$time, $pkg; +} + +sub FETCH { (HIRES ? Time::HiRes::time() : time()) - ${$_[0]}; } +sub STORE { ${$_[0]} = (HIRES ? Time::HiRes::time() : time()) - $_[1]; } + +1; + |
