github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

melo / perl-examples

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Small examples, or proof of concepts — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Updated comparison between fast_stats.pl and stats_basic_optimized.pl 
melo (author)
Mon Oct 19 05:39:21 -0700 2009
commit  6faf812492610d6526580e21adf8b67a7651fd57
tree    4ed1137a9e608cdd6a523f7997cb7056b0efcb64
parent  d639f5b200618413eafee715058b0d4a5df83c24
perl-examples / nfsd_report_bench / max_line_rate.pl nfsd_report_bench/max_line_rate.pl
100755 81 lines (61 sloc) 1.602 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env perl
 
use strict;
use warnings;
use Time::HiRes qw( gettimeofday tv_interval );
 
my $mask = shift || 18; ## report every 256k lines
my $size = shift || 2**20; ## 1Mb default
$mask = 2**$mask - 1;
 
my $lines = my $ll = 0;
 
$SIG{INT} = sub {
  report(1);
  exit;
};
 
system("ps l | egrep 'PID|$$' | grep -v egrep");
 
print "\n\nReading line, performance report every "
  . ($mask + 1)
  . " lines\n";
print "\nPress Ctrl-C to stop with a final report (pid $$)\n\n";
 
my $buf = '';
my $offset = 0;
my ($ts, $type, $op, $bytes);
my $t0 = my $tl = [gettimeofday];
my $read = my $rr = 0;
while () {
  my $n = sysread(\*STDIN, $buf, $size, length($buf));
 
  while ($buf =~ /(.+)\n/gc) {
    $lines++;
    $_ = $1;
    /^(\d+)/gc; $ts = $1;
    /(\w)\sV/gc; $type = $1;
    /\s(\d+)\s\w/gc; $op = $1;
    /\w\s(\d+)\s/gc; $bytes = $1;
 
    report() unless $lines & $mask;
  }
  last unless $n > 0;
 
  $buf = substr($buf, pos($buf));
  $read += $n;
}
 
report(1);
 
sub report {
  my ($final) = @_;
 
  my $now = [gettimeofday];
  my $d = tv_interval(($final ? $t0 : $tl), $now);
  $tl = $now;
 
  my $l = $lines;
  $l -= $ll unless $final;
  $ll = $lines;
 
  my $r = $read;
  $r -= $rr unless $final;
  $rr = $read;
  $r >>= 20;
 
  my $l_rate = $d ? int($l / $d) : 'n/a';
my $r_rate = $d ? $r / $d : 'n/a';
 
print "\n\nFINAL REPORT:\n\n" if $final;
print "elapsed $d, lines $lines, rate $l_rate lines/sec (read "
. ($read >> 20)
. " MB, rate $r_rate MB/sec)\n";
 
if ($final) {
print "\n\n";
system("ps l | egrep 'PID|$$' | grep -v egrep");
  }
}
 
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server