[1194] | 1 | /*
|
---|
| 2 | root -l examples/MemoryUsage.C\(\"ps_output.txt\"\)
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #include "Riostream.h"
|
---|
| 6 |
|
---|
| 7 | static const Font_t kExRootFont = 42;
|
---|
| 8 | static const Float_t kExRootFontSize = 0.04;
|
---|
| 9 | static const Color_t kExRootBackgroundColor = 10;
|
---|
| 10 |
|
---|
| 11 | //------------------------------------------------------------------------------
|
---|
| 12 |
|
---|
| 13 | TGraph grvsz, grrss;
|
---|
[1197] | 14 | TLegend legend(0.41, 0.58, 0.77, 0.67);
|
---|
[1194] | 15 |
|
---|
[1197] | 16 | TCanvas *canvas;
|
---|
| 17 |
|
---|
[1194] | 18 | //------------------------------------------------------------------------------
|
---|
| 19 |
|
---|
| 20 | void MemoryUsage(const char *inputFile)
|
---|
| 21 | {
|
---|
| 22 | Int_t i, vsz, rss;
|
---|
| 23 | ifstream in;
|
---|
| 24 |
|
---|
| 25 | TDirectory *currentDirectory = gDirectory;
|
---|
| 26 |
|
---|
| 27 | // Graphics style parameters to avoid grey background on figures
|
---|
| 28 | gStyle->SetCanvasColor(kExRootBackgroundColor);
|
---|
| 29 | gStyle->SetStatColor(kExRootBackgroundColor);
|
---|
| 30 | // gStyle->SetTitleColor(kExRootBackgroundColor);
|
---|
| 31 | gStyle->SetPadColor(kExRootBackgroundColor);
|
---|
| 32 |
|
---|
| 33 | gStyle->SetPadTopMargin(0.10);
|
---|
| 34 | gStyle->SetPadRightMargin(0.10);
|
---|
| 35 | gStyle->SetPadBottomMargin(0.15);
|
---|
| 36 | gStyle->SetPadLeftMargin(0.15);
|
---|
| 37 |
|
---|
| 38 | gStyle->SetStatFont(kExRootFont);
|
---|
| 39 | gStyle->SetStatFontSize(kExRootFontSize);
|
---|
| 40 |
|
---|
| 41 | gStyle->SetTitleFont(kExRootFont, "");
|
---|
| 42 | gStyle->SetTitleFont(kExRootFont, "X");
|
---|
| 43 | gStyle->SetTitleFont(kExRootFont, "Y");
|
---|
| 44 | gStyle->SetTitleFont(kExRootFont, "Z");
|
---|
| 45 | gStyle->SetTitleSize(kExRootFontSize, "");
|
---|
| 46 | gStyle->SetTitleSize(kExRootFontSize, "X");
|
---|
| 47 | gStyle->SetTitleSize(kExRootFontSize, "Y");
|
---|
| 48 | gStyle->SetTitleSize(kExRootFontSize, "Z");
|
---|
| 49 |
|
---|
| 50 | gStyle->SetLabelFont(kExRootFont, "X");
|
---|
| 51 | gStyle->SetLabelFont(kExRootFont, "Y");
|
---|
| 52 | gStyle->SetLabelFont(kExRootFont, "Z");
|
---|
| 53 | gStyle->SetLabelSize(kExRootFontSize, "X");
|
---|
| 54 | gStyle->SetLabelSize(kExRootFontSize, "Y");
|
---|
| 55 | gStyle->SetLabelSize(kExRootFontSize, "Z");
|
---|
| 56 |
|
---|
| 57 | gStyle->SetPadTickX(1);
|
---|
| 58 | gStyle->SetPadTickY(1);
|
---|
| 59 |
|
---|
| 60 | gStyle->SetTextFont(kExRootFont);
|
---|
| 61 | gStyle->SetTextSize(kExRootFontSize);
|
---|
| 62 |
|
---|
| 63 | gStyle->SetOptStat(111110);
|
---|
| 64 | // gStyle->SetOptFit(101);
|
---|
| 65 |
|
---|
| 66 | canvas = static_cast<TCanvas*>(gROOT->FindObject("c1"));
|
---|
| 67 | if(canvas)
|
---|
| 68 | {
|
---|
| 69 | canvas->Clear();
|
---|
| 70 | canvas->UseCurrentStyle();
|
---|
| 71 | canvas->SetWindowSize(800, 650);
|
---|
| 72 | }
|
---|
| 73 | else
|
---|
| 74 | {
|
---|
| 75 | canvas = new TCanvas("c1", "c1", 800, 650);
|
---|
| 76 | }
|
---|
[1197] | 77 | canvas->SetGrid();
|
---|
[1194] | 78 | canvas->SetHighLightColor(kExRootBackgroundColor);
|
---|
| 79 |
|
---|
| 80 | currentDirectory->cd();
|
---|
| 81 |
|
---|
| 82 | grvsz.SetPoint(1, 0.0, 0.0);
|
---|
| 83 | grrss.SetPoint(1, 0.0, 0.0);
|
---|
| 84 |
|
---|
| 85 | in.open(inputFile);
|
---|
| 86 | i = 2;
|
---|
| 87 | while(1)
|
---|
| 88 | {
|
---|
| 89 | in >> vsz >> rss;
|
---|
| 90 | if(!in.good()) break;
|
---|
| 91 | grvsz.SetPoint(i, (i-1)*0.1, vsz);
|
---|
| 92 | grrss.SetPoint(i, (i-1)*0.1, rss);
|
---|
| 93 | ++i;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | grvsz.GetXaxis()->SetLimits(0, 30);
|
---|
| 97 | grvsz.GetXaxis()->SetTitleOffset(1.5);
|
---|
| 98 | grvsz.GetYaxis()->SetTitleOffset(1.75);
|
---|
| 99 | grvsz.GetXaxis()->SetTitle("time, s");
|
---|
| 100 | grvsz.GetYaxis()->SetTitle("memory usage, kB");
|
---|
[1202] | 101 | grvsz.SetLineColor(kBlack);
|
---|
| 102 | grrss.SetLineColor(kBlack);
|
---|
| 103 | grvsz.SetLineStyle(kDashed);
|
---|
| 104 | grrss.SetLineStyle(kSolid);
|
---|
| 105 | grvsz.SetLineWidth(3);
|
---|
| 106 | grrss.SetLineWidth(3);
|
---|
[1194] | 107 | grvsz.Draw("AL");
|
---|
| 108 | grrss.Draw("L");
|
---|
[1197] | 109 |
|
---|
| 110 | legend.SetTextSize(kExRootFontSize);
|
---|
| 111 | legend.SetTextFont(kExRootFont);
|
---|
| 112 | legend.SetFillColor(kExRootBackgroundColor);
|
---|
| 113 | legend.SetBorderSize(0);
|
---|
[1202] | 114 | legend.AddEntry(&grvsz, "virtual memory", "l");
|
---|
| 115 | legend.AddEntry(&grrss, "physical memory", "l");
|
---|
[1197] | 116 | legend.Draw();
|
---|
[1194] | 117 | }
|
---|
| 118 |
|
---|