3 use lib qw( @prefix@/lib/perl );
7 # this simpulates a standard mrtg-2.x setup ... we can use this to
8 # compare performance ...
14 $RRD = "piped-demo.rrd";
15 $SVG = "piped-demo.svg";
16 $PNG = "piped-demo.png";
18 # some magic to find the correct rrdtol executable
19 if ( -x "@exec_prefix@/bin/rrdtool") {
20 RRDp::start "@exec_prefix@/bin/rrdtool";
21 } elsif ( -x "../bin/rrdtool") {
22 RRDp::start "../bin/rrdtool";
24 RRDp::start "../src/rrdtool";
27 print "* Creating RRD with properties equivalent to mrtg-2.x logfile\n\n";
29 $START = time()-$RUNS*$STEP;
31 RRDp::cmd "create $RRD -b $START -s $STEP
37 RRA:AVERAGE:0.5:24:600
39 RRA:AVERAGE:0.5:144:600
43 ($user,$sys,$real) = ($RRDp::user,$RRDp::sys,$RRDp::real);
45 print "* Filling RRD with $RUNS Values. One moment please ...\n";
46 print " If you are running over NFS this will take *MUCH* longer\n\n";
49 $i<$START+$STEP*$RUNS;
50 $i+=$STEP+int((rand()-0.5)*7)){
52 $line = "update $RRD $i:".int(rand(100000)).":".int(rand(100000));
57 ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real);
59 printf "-- performance analysis Update test\n".
60 " usr/upd: %1.5fs sys/upd: %1.5fs real/upd: %1.5fs upd/sec: %1.0f\n",
61 ($user1-$user)/($RUNS), ($sys1-$sys)/($RUNS),
62 ($real1-$real)/($RUNS), ($RUNS)/($real1-$real);
64 # creating some graphs
66 print "* Creating $GRUNS SVG graphs: $SVG\n\n";
68 $localtime = scalar localtime(time);
69 $localtime = s/:/\\:/g;
70 for ($i=0;$i<$GRUNS;$i++) {
71 RRDp::cmd "graph $SVG ", "--title 'Test GRAPH' ",
72 "--imgformat SVG --height 150 --vertical-label 'Dummy Units' ".
73 "--start now".(-$RUNS*$STEP),
74 "--color ARROW#bfbfbf",
75 "DEF:alpha=$RRD:in:AVERAGE",
76 "DEF:beta=$RRD:out:AVERAGE",
77 "CDEF:calc=alpha,beta,+,1.5,/",
78 "AREA:alpha#0022e9:Alpha",
79 "STACK:beta#00b871:Beta",
80 "STACK:calc#ff0091:Calc\\j",
81 "PRINT:alpha:AVERAGE:'Average Alpha\\: %1.2lf %S'",
82 "PRINT:alpha:MIN:'Min Alpha\\: %1.2lf %S'",
83 "PRINT:alpha:MAX:'Max Alpha\\: %1.2lf %S'",
84 "GPRINT:calc:AVERAGE:'Average calc\\: %1.2lf %S\\r'",
85 "GPRINT:calc:MIN:'Min calc\\: %1.2lf %S'",
86 "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'",
87 "VRULE:".($now-3600)."#008877:'60 Minutes ago'",
89 "COMMENT:'Graph created on\\: ".$localtime."\\c'";
93 ($user2,$sys2,$real2) = ($RRDp::user,$RRDp::sys,$RRDp::real);
95 print "ANSWER:\n$$answer";
97 printf "\n-- average Time for one Graph\n".
98 " usr/grf: %1.5fs sys/grf: %1.5fs real/grf: %1.5fs graphs/sec: %1.2f\n",
99 ($user2-$user1)/$GRUNS,
100 ($sys2-$sys1)/$GRUNS,
101 ($real2-$real1)/$GRUNS,
102 $GRUNS/($real2-$real1);
104 print "\n\n* Creating $GRUNS PNG graphs: $PNG\n\n";
107 ($user1,$sys1,$real1) = ($RRDp::user,$RRDp::sys,$RRDp::real);
108 my $local = "".localtime(time());
111 for ($i=0;$i<$GRUNS;$i++) {
112 RRDp::cmd "graph $PNG ", "--title 'Test GRAPH' ",
113 "--imgformat PNG --height 150 --vertical-label 'Dummy Units' ".
114 "--start now".(-$RUNS*$STEP),
115 "--color ARROW#bfbfbf",
116 "DEF:alpha=$RRD:in:AVERAGE",
117 "DEF:beta=$RRD:out:AVERAGE",
118 "CDEF:calc=alpha,beta,+,1.5,/",
119 "AREA:alpha#0022e9:Alpha",
120 "STACK:beta#00b871:Beta",
121 "STACK:calc#ff0091:Calc\\j",
122 "PRINT:alpha:AVERAGE:'Average Alpha\\: %1.2lf %S'",
123 "PRINT:alpha:MIN:'Min Alpha\\: %1.2lf %S'",
124 "PRINT:alpha:MAX:'Max Alpha\\: %1.2lf %S'",
125 "GPRINT:calc:AVERAGE:'Average calc\\: %1.2lf %S\\r'",
126 "GPRINT:calc:MIN:'Min calc\\: %1.2lf %S'",
127 "GPRINT:calc:MAX:'Max calc\\: %1.2lf %S'",
128 "VRULE:".($now-3600)."#008877:'60 Minutes ago'",
130 "COMMENT:'Graph created on\\: $local\\c'";
132 $answer = RRDp::read;
134 ($user2,$sys2,$real2) = ($RRDp::user,$RRDp::sys,$RRDp::real);
136 print "ANSWER:\n$$answer";
138 printf "\n-- average Time for one PNG Graph\n".
139 " usr/grf: %1.5fs sys/grf: %1.5fs real/grf: %1.5fs".
140 " graphs/sec: %1.2f\n\n",
141 ($user2-$user1)/$GRUNS,
142 ($sys2-$sys1)/$GRUNS,
143 ($real2-$real1)/$GRUNS,
144 $GRUNS/($real2-$real1);