Fork me on GitHub

source: git/examples/MemoryUsage.C@ 239e1d0

ImprovedOutputFile Timing dual_readout llp 3.3.3pre11
Last change on this file since 239e1d0 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
RevLine 
[405a724]1/*
[21f3c04]2root -l examples/MemoryUsage.C'("ps_output.txt")'
[405a724]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;
[b645237]14TLegend legend(0.41, 0.59, 0.77, 0.68);
[a9d423d]15
16TCanvas *canvas;
[405a724]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 }
[a9d423d]77 canvas->SetGrid();
[405a724]78 canvas->SetHighLightColor(kExRootBackgroundColor);
79
80 currentDirectory->cd();
81
[3f4901e]82 grvsz.SetPoint(0, 0.0, 0.0);
83 grrss.SetPoint(0, 0.0, 0.0);
[405a724]84
85 in.open(inputFile);
[3f4901e]86 i = 1;
[405a724]87 while(1)
88 {
89 in >> vsz >> rss;
90 if(!in.good()) break;
[b645237]91 grvsz.SetPoint(i, (i-1)*0.1, vsz/1024.0);
92 grrss.SetPoint(i, (i-1)*0.1, rss/1024.0);
[405a724]93 ++i;
94 }
[b645237]95 grvsz.SetPoint(i, (i-1)*0.1, 0.0);
96 grrss.SetPoint(i, (i-1)*0.1, 0.0);
[405a724]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");
[b645237]102 grvsz.GetYaxis()->SetTitle("memory usage, MB");
[d6eccdb]103 grvsz.SetLineColor(15);
[78844a1]104 grrss.SetLineColor(kBlack);
[b645237]105 grvsz.SetLineStyle(kSolid);
[78844a1]106 grrss.SetLineStyle(kSolid);
107 grvsz.SetLineWidth(3);
108 grrss.SetLineWidth(3);
[405a724]109 grvsz.Draw("AL");
110 grrss.Draw("L");
[a9d423d]111
112 legend.SetTextSize(kExRootFontSize);
113 legend.SetTextFont(kExRootFont);
114 legend.SetFillColor(kExRootBackgroundColor);
115 legend.SetBorderSize(0);
[78844a1]116 legend.AddEntry(&grvsz, "virtual memory", "l");
117 legend.AddEntry(&grrss, "physical memory", "l");
[a9d423d]118 legend.Draw();
[405a724]119}
120
Note: See TracBrowser for help on using the repository browser.