Skip to content

Conversation

LebedevRI
Copy link
Collaborator

Ok, so, i'm still trying to get to the state when it will be a trivial change to report all the separate iterations.
The old code (LHS of the diff) was rather convoluted i'd say.
I have tried to refactor it a bit into small logical chunks, with proper comments.
As far as i can tell, i preserved the intent of the code, what it was doing before.
The road forward still isn't clear, but i'm quite sure it's not with the old code :)

@coveralls
Copy link

coveralls commented Sep 25, 2018

Coverage Status

Coverage increased (+0.2%) to 89.256% when pulling b3ec1c8 on LebedevRI:refactor-RunBenchmark into edc77a3 on google:master.

@AppVeyorBot
Copy link

Build benchmark 1470 failed (commit 93720b92ec by @LebedevRI)

@AppVeyorBot
Copy link

Build benchmark 1471 failed (commit b7ef961139 by @LebedevRI)

src/benchmark.cc Outdated
}

return run_results;
RunResults getResults() { return run_results; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm torn between this, where you have a simple accessor but the constructor is complex and actually doing the work, and an alternative where the constructor merely initialises the state, and a method Run that runs the benchmark and returns RunResults.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i don't like this, too.
The current approach (complex constructor) seems better,
because we really wouldn't want to re-run re-use
the same BenchmarkRunner instance more than once.

@dmah42
Copy link
Member

dmah42 commented Sep 26, 2018

This seems to work really well. I wonder if it's worth extracting the class into a benchmark_runner.cc implementation file to help reduce the overwhelming benchmark.cc file size.

@LebedevRI
Copy link
Collaborator Author

This seems to work really well.

Well, it should be the same algo, just less, convoluted?

I wonder if it's worth extracting the class into a benchmark_runner.cc implementation file to help reduce the overwhelming benchmark.cc file size.

Done, better?

@AppVeyorBot
Copy link

Build benchmark 1487 failed (commit c356a2f34d by @LebedevRI)

@LebedevRI
Copy link
Collaborator Author

Anything more to do here?

From my side, all the follow-up work in benchmark_runner.cc will be in follow-up pr,
once i'm aware what it is..

@LebedevRI LebedevRI force-pushed the refactor-RunBenchmark branch from 7406c89 to 1267547 Compare September 28, 2018 20:53
@AppVeyorBot
Copy link

Build benchmark 1494 failed (commit c7a3c9277c by @LebedevRI)

@AppVeyorBot
Copy link

Build benchmark 1495 completed (commit fdd6be7f6c by @LebedevRI)

}
}

RunResults getResults() { return run_results; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

google-style: get_results()

also, mark the method as const?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even the current non-const variant is not what i wanted..
https://godbolt.org/z/7ALmcF

size_t iters;
double seconds;
};
IterationResults doNIterations() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DoNIterations

return i;
}

size_t predictNumItersNeeded(const IterationResults& i) const {
Copy link
Member