I have a compiled code which saves a plotted TGraph (“g”) in a GIF file. It looks like this:
TCanvas *Wcan = new TCanvas("WcanTP","WcanTP",0,0,750,500);
Wcan->Draw();
TPad *Wpad = new TPad("WpadTP","WpadTP",0,0,1,1);
Wpad->Draw();
Wpad->cd();
g->Draw("AP");
Wcan->SaveAs("./mygraph.gif")
The graph “g” is pretty big: ~1,000,000 points. It takes a long time (more than one minute) to perform the “SaveAs()” function.
What I don’t understand is that it takes about 1 second when I perform the same list of commands interactively with ROOT. I’d like to have a compiled code which runs just as fast. What should I do?
are you sure the time is spent saving the file? This seems to take the same amount of time in interpreted, compiled with ACLiC and with a proper compiler for me with root-5.34.03. This was my test code:
Sorry, it took me some time to come back to this post. I used your code and indeed I don’t see any difference between the interpreter and the compiled code.
However I identified the reason why my code is so slow. If you add the following style command:
g->SetMarkerStyle(20);
saving the plot as a GIFF file takes much much longer. Is there a fundamental reason for this behavior?
Thank you,