5 # Created By Tobi Oetiker <tobi@oetiker.ch>
8 #makes programm work AFTER install
10 use lib qw( @prefix@/lib/perl );
14 RRDtool Performance Tester
15 --------------------------
16 This Program will create an increassing number of rrds and update them.
17 The rrds are modeld after what mrtg would create. The Program
18 will report the number of updates that can be performed per second.
19 Since rrdtool update performance is helped greatly by the disk cache,
20 you will observe a sharp drop in performance once the cache is
21 exhausted. The program tries to detect this change and stop running.
26 use Time::HiRes qw(time);
32 RRDs::create ( $file.".rrd", qw(
39 RRA:AVERAGE:0.5:24:600
41 RRA:AVERAGE:0.5:144:600
44 my $total = time - $start;
45 my $error = RRDs::error;
53 my $in = int(rand(1000));
54 my $out = int(rand(1000));
56 RRDs::update ($file.".rrd", $time.":$in:$out");
57 my $total = time - $start;
58 my $error = RRDs::error;
63 sub stddev ($$$){ #http://en.wikipedia.org/wiki/Standard_deviation
65 my $squaresum = shift;
67 return sqrt( 1 / $count * ( $squaresum - $sum*$sum / $count ))
70 mkdir "db-$$" or die $!;
82 # create ###############################################################
87 for(my $db=$createddbs;$db<$totaldbs;$db++){
88 # make sure we do not get bitten by
89 # expensive directory searches
90 # store 100 rrds per directory.
91 my $id = sprintf ("%06d",$db);
92 $id =~ s/^(.)(.)(.)(.)//;
93 $path{$db}="$1/$2/$3/$4/$id";
94 -d "$1" or mkdir "$1";
95 -d "$1/$2" or mkdir "$1/$2";
96 -d "$1/$2/$3" or mkdir "$1/$2/$3";
97 -d "$1/$2/$3/$4" or mkdir "$1/$2/$3/$4";
101 my $total = create $path{$db};
103 $squaresum += $total*$total;
106 printf STDERR "Create %6d rrds %6d c/s (%6.5f sdv)",$count,$count/$sum,stddev($sum,$squaresum,$count);
108 # update #################################################################
115 for(my $db=0;$db<$totaldbs;$db++){
116 my $total = update($path{$db},$time);
118 $squaresum += $total*$total;
122 last if time - $now > 5; # stop testing after 5 seconds or one round
124 my $ups = $count/$sum;
125 my $sdv = stddev($sum,$squaresum,$count);
126 printf STDERR " Update %6d rrds %6d u/s (%6.5f sdv)\n",$totaldbs,$ups,$sdv;
128 if ((not $prevups or $prevups / $ups < 2 or $totaldbs < 500 )and $over < 1){
130 } elsif ( $over < 1 ) {
131 # just run another round to see if we realy hit the block
137 * Stopping test since your system seems to have hit the cache barrier.
139 * You may want to run the test repeatedly to be sure that
140 your system has not been busy with something other than
143 * If you increas the number of rrd files above the cache barrier,
144 the perfomance penalty should be linear.
146 * Remove the test tree in db-$$