Fork me on GitHub

source: svn/trunk/examples/MemoryUsage.C@ 1196

Last change on this file since 1196 was 1194, checked in by Pavel Demin, 11 years ago

add MemoryUsage.C

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 2.7 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;
14
15//------------------------------------------------------------------------------
16
17void MemoryUsage(const char *inputFile)
18{
19 Int_t i, vsz, rss;
20 ifstream in;
21
22 TDirectory *currentDirectory = gDirectory;
23
24 // Graphics style parameters to avoid grey background on figures
25 gStyle->SetCanvasColor(kExRootBackgroundColor);
26 gStyle->SetStatColor(kExRootBackgroundColor);
27 // gStyle->SetTitleColor(kExRootBackgroundColor);
28 gStyle->SetPadColor(kExRootBackgroundColor);
29
30 gStyle->SetPadTopMargin(0.10);
31 gStyle->SetPadRightMargin(0.10);
32 gStyle->SetPadBottomMargin(0.15);
33 gStyle->SetPadLeftMargin(0.15);
34
35 gStyle->SetStatFont(kExRootFont);
36 gStyle->SetStatFontSize(kExRootFontSize);
37
38 gStyle->SetTitleFont(kExRootFont, "");
39 gStyle->SetTitleFont(kExRootFont, "X");
40 gStyle->SetTitleFont(kExRootFont, "Y");
41 gStyle->SetTitleFont(kExRootFont, "Z");
42 gStyle->SetTitleSize(kExRootFontSize, "");
43 gStyle->SetTitleSize(kExRootFontSize, "X");
44 gStyle->SetTitleSize(kExRootFontSize, "Y");
45 gStyle->SetTitleSize(kExRootFontSize, "Z");
46
47 gStyle->SetLabelFont(kExRootFont, "X");
48 gStyle->SetLabelFont(kExRootFont, "Y");
49 gStyle->SetLabelFont(kExRootFont, "Z");
50 gStyle->SetLabelSize(kExRootFontSize, "X");
51 gStyle->SetLabelSize(kExRootFontSize, "Y");
52 gStyle->SetLabelSize(kExRootFontSize, "Z");
53
54 gStyle->SetPadTickX(1);
55 gStyle->SetPadTickY(1);
56
57 gStyle->SetTextFont(kExRootFont);
58 gStyle->SetTextSize(kExRootFontSize);
59
60 gStyle->SetOptStat(111110);
61 // gStyle->SetOptFit(101);
62
63 canvas = static_cast<TCanvas*>(gROOT->FindObject("c1"));
64 if(canvas)
65 {
66 canvas->Clear();
67 canvas->UseCurrentStyle();
68 canvas->SetWindowSize(800, 650);
69 }
70 else
71 {
72 canvas = new TCanvas("c1", "c1", 800, 650);
73 }
74 canvas->SetLogy(0);
75 canvas->SetHighLightColor(kExRootBackgroundColor);
76
77 currentDirectory->cd();
78
79 grvsz.SetPoint(1, 0.0, 0.0);
80 grrss.SetPoint(1, 0.0, 0.0);
81
82 in.open(inputFile);
83 i = 2;
84 while(1)
85 {
86 in >> vsz >> rss;
87 if(!in.good()) break;
88 grvsz.SetPoint(i, (i-1)*0.1, vsz);
89 grrss.SetPoint(i, (i-1)*0.1, rss);
90 ++i;
91 }
92
93 grvsz.GetXaxis()->SetLimits(0, 30);
94 grvsz.GetXaxis()->SetTitleOffset(1.5);
95 grvsz.GetYaxis()->SetTitleOffset(1.75);
96 grvsz.GetXaxis()->SetTitle("time, s");
97 grvsz.GetYaxis()->SetTitle("memory usage, kB");
98 grvsz.SetLineColor(kRed);
99 grrss.SetLineColor(kMagenta);
100 grvsz.SetLineWidth(2);
101 grrss.SetLineWidth(2);
102 grvsz.Draw("AL");
103 grrss.Draw("L");
104}
105
Note: See TracBrowser for help on using the repository browser.