Skip to content

Commit 8845c14

Browse files
author
sarathnandu
committed
Updates based on review comments.
1 parent 31e2863 commit 8845c14

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

examples/common/utility/utility.hpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,12 @@ class measurements {
366366
}
367367
measurements(int iterations) {
368368
_time_intervals.reserve(iterations);
369-
clear();
370-
}
371-
void clear() {
372-
_time_intervals.clear();
373369
}
374-
void start() {
370+
371+
inline void start() {
375372
_startTime = std::chrono::steady_clock::now();
376373
}
377-
void stop() {
374+
inline void stop() {
378375
auto _endTime = std::chrono::steady_clock::now();
379376
// store the end time and start time
380377
_time_intervals.push_back(std::make_pair(_startTime, _endTime));
@@ -388,21 +385,25 @@ class measurements {
388385
auto total_duration = std::accumulate(
389386
_time_intervals.begin(),
390387
_time_intervals.end(),
391-
0, // Start with 0 count
388+
0, // Start with 0 count
392389
[](long long total, const std::pair<time_point, time_point>& interval) {
393390
// Compute the difference and add it to the total
394-
return total + std::chrono::duration_cast<std::chrono::microseconds>(interval.second - interval.first).count();
395-
}
396-
);
391+
return total + std::chrono::duration_cast<std::chrono::microseconds>(
392+
interval.second - interval.first)
393+
.count();
394+
});
397395
long long averageTimePerFrame = total_duration / _time_intervals.size();
398396
long long sumOfSquareDiff = 0;
399397
std::for_each(_time_intervals.begin(),
400398
_time_intervals.end(),
401-
[&](const std::pair<time_point, time_point>& interval) {
402-
long long duration = std::chrono::duration_cast<std::chrono::microseconds>(interval.second - interval.first).count();
403-
long long diff = duration - averageTimePerFrame;
404-
sumOfSquareDiff += diff * diff;
405-
});
399+
[&](const std::pair<time_point, time_point>& interval) {
400+
long long duration =
401+
std::chrono::duration_cast<std::chrono::microseconds>(
402+
interval.second - interval.first)
403+
.count();
404+
long long diff = duration - averageTimePerFrame;
405+
sumOfSquareDiff += diff * diff;
406+
});
406407
double stdDev = std::sqrt(sumOfSquareDiff / _time_intervals.size());
407408
double relError = 100 * (stdDev / averageTimePerFrame);
408409
return relError;
@@ -411,7 +412,7 @@ class measurements {
411412
private:
412413
using time_point = std::chrono::steady_clock::time_point;
413414
time_point _startTime;
414-
std::vector< std::pair<time_point, time_point> > _time_intervals;
415+
std::vector<std::pair<time_point, time_point>> _time_intervals;
415416
};
416417

417418
namespace internal {

examples/parallel_for/seismic/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ int main(int argc, char *argv[]) {
9999
std::cout << "Substituting 1000 for unlimited frames because not running interactively"
100100
<< "\n";
101101
}
102+
// TODO : Extend utility::cli_argument_pack() toallow specifying the default value.
102103
if (options.numberofIterations == 0) {
103104
options.numberofIterations = 10;
104105
std::cout << "Setting the number of iterations = 10 default"

0 commit comments

Comments
 (0)