Fork me on GitHub

source: git/examples/MemoryUsage.C@ c04eb8a

ImprovedOutputFile Timing dual_readout llp
Last change on this file since c04eb8a was 21f3c04, checked in by Pavel Demin <demin@…>, 10 years ago

replace \(\"...\"\) with '("...")' in ROOT command line examples

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2root -l examples/MemoryUsage.C'("ps_output.txt")'
3*/
4
5#include "Riostream.h"
6
7static const Font_t kExRootFont = 42;
8static const Float_t kExRootFontSize = 0.04;
9static const Color_t kExRootBackgroundColor = 10;
10
11//------------------------------------------------------------------------------
12
13TGraph grvsz, grrss;
14TLegend legend(0.41, 0.59, 0.77, 0.68);
15
16TCanvas *canvas;
17
18//------------------------------------------------------------------------------
19
20void 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 }
77 canvas->SetGrid();
78 canvas->SetHighLightColor(kExRootBackgroundColor);
79
80 currentDirectory->cd();
81
82 grvsz.SetPoint(0, 0.0, 0.0);
83 grrss.SetPoint(0, 0.0, 0.0);
84
85 in.open(inputFile);
86 i = 1;
87 while(1)
88 {
89 in >> vsz >> rss;
90 if(!in.good()) break;
91 grvsz.SetPoint(i, (i-1)*0.1, vsz/1024.0);
92 grrss.SetPoint(i, (i-1)*0.1, rss/1024.0);
93 ++i;
94 }
95 grvsz.SetPoint(i, (i-1)*0.1, 0.0);
96 grrss.SetPoint(i, (i-1)*0.1, 0.0);
97
98 grvsz.GetXaxis()->SetLimits(0, 30);
99 grvsz.GetXaxis()->SetTitleOffset(1.5);
100 grvsz.GetYaxis()->SetTitleOffset(1.75);
101 grvsz.GetXaxis()->SetTitle("time, s");
102 grvsz.GetYaxis()->SetTitle("memory usage, MB");
103 grvsz.SetLineColor(15);
104 grrss.SetLineColor(kBlack);
105 grvsz.SetLineStyle(kSolid);
106 grrss.SetLineStyle(kSolid);
107 grvsz.SetLineWidth(3);
108 grrss.SetLineWidth(3);
109 grvsz.Draw("AL");
110 grrss.Draw("L");
111
112 legend.SetTextSize(kExRootFontSize);
113 legend.SetTextFont(kExRootFont);
114 legend.SetFillColor(kExRootBackgroundColor);
115 legend.SetBorderSize(0);
116 legend.AddEntry(&grvsz, "virtual memory", "l");
117 legend.AddEntry(&grrss, "physical memory", "l");
118 legend.Draw();
119}
120
Note: See TracBrowser for help on using the repository browser.