3 #makes things work when run without install
4 use lib qw( ../libraries/perl-piped/blib/lib ../lib/perl );
6 #makes programm work AFTER install
7 use lib qw( /usr/local/rrdtool-1.0.33/lib/perl );
11 # this simpulates a standard mrtg-2.x setup ... we can use this to
12 # compare performance ...
18 $RRD = "piped-demo.rrd";
19 $GIF = "piped-demo.gif";
20 $PNG = "piped-demo.png";
22 # some magic to find the correct rrdtol executable
23 if ( -x "/usr/local/rrdtool-1.0.33/bin/rrdtool") {
24 RRDp::start "/usr/local/rrdtool-1.0.33/bin/rrdtool";
25 } elsif ( -x "../bin/rrdtool") {
26 RRDp::start "../bin/rrdtool";
28 RRDp::start "../src/rrdtool";
31 print "* Creating RRD with properties equivalent to mrtg-2.x logfile\n\n";
33 $START = time()-$RUNS*$STEP;
35 RRDp::cmd "create $RRD -b $START -s $STEP
41 RRA:AVERAGE:0.5:24:600
43 RRA:AVERAGE:0.5:144:600
47 ($user,$sys,$real) = ($RRDp::user,$RRDp::sys,$RRDp::real);
49 print "* Filling RRD with $RUNS Values. One moment please ...\n";
50 print " If you are running over NFS this will take *MUCH* longer\n\n";
53 $i<$START+$STEP*$RUNS;
54 $i+=$STEP+int((rand()-0.5)*7)){
56 $line = "update $RRD $i:".int(rand(100000)).":".int(rand(100000));
61 ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real);
63 printf "-- performance analysis Update test\n".
64 " usr/upd: %1.5fs sys/upd: %1.5fs real/upd: %1.5fs upd/sec: %1.0f\n",
65 ($user1-$user)/($RUNS), ($sys1-$sys)/($RUNS),
66 ($real1-$real)/($RUNS), ($RUNS)/($real1-$real);
68 # creating some graphs
70 print "* Creating $GRUNS GIF graphs: $GIF\n\n";
72 for ($i=0;$i<$GRUNS;$i++) {
73 RRDp::cmd "graph $GIF ", "--title 'Test GRAPH' ",
74 "--height 150 --vertical-label 'Dummy Units' ".
75 "--start now".(-$RUNS*$STEP),
76 "--color ARROW#bfbfbf",
77 "DEF:alpha=$RRD:in:AVERAGE",
78 "DEF:beta=$RRD:out:AVERAGE",
79 "CDEF:calc=alpha,beta,+,1.5,/",
80 "AREA:alpha#0022e9:Alpha",
81 "STACK:beta#00b871:Beta",
82 "STACK:calc#ff0091:Calc\\j",
83 "PRINT:alpha:AVERAGE:'Average Alpha\\: %1.2lf %S'",
84 "PRINT:alpha:MIN:'Min Alpha\\: %1.2lf %S'",
85 "PRINT:alpha:MAX:'Max Alpha\\: %1.2lf %S'",
86 "GPRINT:calc:AVERAGE:'Average calc\\: %1.2lf %S\\r'",
87 "GPRINT:calc:MIN:'Min calc\\: %1.2lf %S'",
88 "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'",
89 "VRULE:".($now-3600)."#008877:'60 Minutes ago'",
91 "COMMENT:'Graph created on: ".localtime(time())."\\c'";
95 ($user2,$sys2,$real2) = ($RRDp::user,$RRDp::sys,$RRDp::real);
97 print "ANSWER:\n$$answer";
99 printf "\n-- average Time for one Graph\n".
100 " usr/grf: %1.5fs sys/grf: %1.5fs real/grf: %1.5fs graphs/sec: %1.2f\n",
101 ($user2-$user1)/$GRUNS,
102 ($sys2-$sys1)/$GRUNS,
103 ($real2-$real1)/$GRUNS,
104 $GRUNS/($real2-$real1);
106 print "\n\n* Creating $GRUNS PNG graphs: $PNG\n\n";
109 ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real);
110 for ($i=0;$i<$GRUNS;$i++) {
111 RRDp::cmd "graph $PNG ", "--title 'Test GRAPH' ",
112 "--imgformat PNG --height 150 --vertical-label 'Dummy Units' ".
113 "--start now".(-$RUNS*$STEP),
114 "--color ARROW#bfbfbf",
115 "DEF:alpha=$RRD:in:AVERAGE",
116 "DEF:beta=$RRD:out:AVERAGE",
117 "CDEF:calc=alpha,beta,+,1.5,/",
118 "AREA:alpha#0022e9:Alpha",
119 "STACK:beta#00b871:Beta",
120 "STACK:calc#ff0091:Calc\\j",
121 "PRINT:alpha:AVERAGE:'Average Alpha\\: %1.2lf %S'",
122 "PRINT:alpha:MIN:'Min Alpha\\: %1.2lf %S'",
123 "PRINT:alpha:MAX:'Max Alpha\\: %1.2lf %S'",
124 "GPRINT:calc:AVERAGE:'Average calc\\: %1.2lf %S\\r'",
125 "GPRINT:calc:MIN:'Min calc\\: %1.2lf %S'",
126 "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'",
127 "VRULE:".($now-3600)."#008877:'60 Minutes ago'",
129 "COMMENT:'Graph created on: ".localtime(time())."\\c'";
131 $answer = RRDp::read;
133 ($user2,$sys2,$real2) = ($RRDp::user,$RRDp::sys,$RRDp::real);
135 print "ANSWER:\n$$answer";
137 printf "\n-- average Time for one PNG Graph\n".
138 " usr/grf: %1.5fs sys/grf: %1.5fs real/grf: %1.5fs".
139 " graphs/sec: %1.2f\n\n",
140 ($user2-$user1)/$GRUNS,
141 ($sys2-$sys1)/$GRUNS,
142 ($real2-$real1)/$GRUNS,
143 $GRUNS/($real2-$real1);