Fork me on GitHub

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

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

increase font size for performance plots

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 3.0 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.58, 0.77, 0.67);
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(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");
101 grvsz.SetLineColor(kRed);
102 grrss.SetLineColor(kMagenta);
103 grvsz.SetLineWidth(2);
104 grrss.SetLineWidth(2);
105 grvsz.Draw("AL");
106 grrss.Draw("L");
107
108 legend.SetTextSize(kExRootFontSize);
109 legend.SetTextFont(kExRootFont);
110 legend.SetFillColor(kExRootBackgroundColor);
111 legend.SetBorderSize(0);
112 legend.AddEntry(&grvsz, "virtual memory size", "l");
113 legend.AddEntry(&grrss, "resident set size", "l");
114 legend.Draw();
115}
116
Note: See TracBrowser for help on using the repository browser.