-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbm_init.C
75 lines (67 loc) · 2.2 KB
/
bm_init.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
R__LOAD_LIBRARY(libMathMore)
void DrawText(TString string, float y, TF1 *fit)
{
TPaveText *pt = new TPaveText(0.2,y,0.5,y+0.05,"tbNDC");
pt->SetBorderSize(0);
pt->SetTextAlign(12);
pt->AddText(string);
pt->Draw();
pt->SetTextColor(fit->GetLineColor());
pt->SetTextSize(0.0375);
}
void bm_init(std::vector<std::string> paths, std::vector<int> bloatFactors)
{
auto N = paths.size();
auto graph = new TGraphErrors();
float maxY = 0.0;
for (unsigned i = 0; i < N; ++i) {
auto f = paths[i];
std::vector<float> realTimes;
realTimes.resize(6);
std::ifstream fileTiming(f.c_str());
std::string line;
while (std::getline(fileTiming, line))
{
std::istringstream iss(line);
std::string what;
iss >> what;
if (what != "realtime:")
continue;
iss >> realTimes[0] >> realTimes[1] >> realTimes[2]
>> realTimes[3] >> realTimes[4] >> realTimes[5];
}
float n = realTimes.size();
float mean = 0.0;
for (auto t : realTimes)
mean += t;
mean /= n;
float s2 = 0.0;
for (auto t : realTimes)
s2 += (t - mean) * (t - mean);
s2 /= (n - 1);
float s = sqrt(s2);
float t = abs(ROOT::Math::tdistribution_quantile(0.05 / 2., n - 1));
float error = t * s / sqrt(n);
maxY = std::max(maxY, mean + error);
graph->SetPoint(i, bloatFactors[i], mean);
graph->SetPointError(i, 0, error);
}
new TCanvas();
graph->SetFillColor(kBlue);
graph->SetLineColor(12);
graph->SetLineWidth(2);
graph->SetMarkerColor(kBlack);
graph->GetYaxis()->SetRangeUser(0, maxY * 1.1);
//graph->GetXaxis()->SetRangeUser(-2, bloatFactors[N-1] + 2);
graph->Draw("ab");
graph->Draw("p");
auto fit = new TF1("fitThroughput", "[0] + x*[1]", bloatFactors[1], bloatFactors[N-1]);
fit->SetLineColor(kRed);
fit->SetLineWidth(2);
graph->Fit(fit);
std::cout << Form("intercept = %2.4f #pm %2.4f s", fit->GetParameter(0),
TMath::Sqrt(fit->GetChisquare() / fit->GetNDF())) << std::endl;
DrawText(Form("intercept = %2.4f #pm %2.4f s", fit->GetParameter(0),
TMath::Sqrt(fit->GetChisquare() / fit->GetNDF())),
maxY, fit);
}