MCPcopy Create free account
hub / github.com/SeisSol/SeisSol / addSample

Method addSample

src/Monitoring/LoopStatistics.cpp:128–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void LoopStatistics::addSample(
129 unsigned region, unsigned numIterations, unsigned subRegion, timespec begin, timespec end) {
130 if (outputSamples) {
131 Sample sample{};
132 sample.begin = begin;
133 sample.end = end;
134 sample.numIters = numIterations;
135 sample.subRegion = subRegion;
136 regions[region].times.emplace_back(sample);
137 }
138 if (numIterations > 0) {
139 auto& vars = regions[region].variables;
140 const auto time = seconds(difftime(begin, end));
141 vars.x += numIterations;
142 vars.x2 += static_cast<double>(numIterations) * static_cast<double>(numIterations);
143 vars.xy += static_cast<double>(numIterations) * time;
144 vars.y += time;
145 vars.y2 += time * time;
146 ++vars.n;
147 }
148}
149
150void LoopStatistics::reset() {
151 for (auto& region : regions) {

Callers 1

exitMethod · 0.80

Calls 2

secondsFunction · 0.85
difftimeFunction · 0.85

Tested by 1

exitMethod · 0.64