|
Speed |
Posted by Leo on Jul-11-2012 12:42 |
|
Hello, Peter,
I find it difficult to speed up the chart processing, I have a generic perl program that
generates 54 simple charts, the program takes 8 to 10 seconds to process all 54 charts,
is there any way I can make it run within 2000 milliseconds?
It is a Linux environment.
Thanks.
code:
~~~~
1 #!/usr/bin/perl
2 use perlchartdir;
3
4 $type = $ARGV[0];
5 $ctext = $ARGV[1];
6 $color = $ARGV[2];
7
8 $color =~ s/1_L//;
9 if ($color % 2) {
10 $usecolor = 0xdddddd;
11 }
12 else {
13 $usecolor = 0xffffff;
14 }
15
16 if ($type =~ m/Bar/) {
17 my $data = [DATAPOINTS];
18 $labels = ["Mon", "Tue", "Wed", "Thu", "Fri"];
19 $c = new XYChart(500, 250);
20 $c->getLegend()->setPos(-9999, -9999);
21 $c->setPlotArea(-1, -1, $c->getWidth() + 0, $c->getHeight() + 2, $usecolor,
$usecolor, $usecolor, $usecolor);
22 if ($type =~ m/BarSpline/) {
23 $layer = $c->addSplineLayer($data, 0x000000);
24 $layer->setLineWidth(25);
25 $layer->addDataSet($data, 0xffffff, "")-
>setDataSymbol($perlchartdir::CircleSymbol, 35);
26 }
27 else {
28 $c->addBarLayer($data, 0x000033)->setBarGap(0.5);
29 }
30 $c->xAxis()->setLabels($labels);
31 $c->yAxis()->addZone(-9999, 0, 0xffcccc);
32 $c->yAxis()->addMark(0, 0xFF0000, "Alert = 0")->setLineWidth(15);
33 $c->xAxis->setColors(0xFF0000,0xFF0000,0xFF0000,0xFF0000);
34 $c->yAxis->setColors(0xFF0000,0xFF0000,0xFF0000,0xFF0000);
35 $c->makeChart("1_PNG");
36 }
37 else { # reserved
38 ;
39 } |
Re: Speed |
Posted by Peter Kwan on Jul-12-2012 01:27 |
|
Hi Leo,
In your code, I can only see it is creating 1 chart, not 54 charts.
Do you mean you have a script that creates 1 chart, and you run the script 54 times (thereby executing the Perl interpreter "#!/usr/bin/perl" 54 times)? As the Perl interpreter has a very high start up overhead, it is quite possible it consumes a lot of CPU time. To improve performance, you may consider to create 1 script that generates 54 charts, so that you only need to start the Perl interpreter one time.
Hope this can help.
Regards
Peter Kwan |
|