Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cmake magic to download google-benchmark, implement benchmark for #1337 #1381

Merged
merged 3 commits into from
Dec 5, 2019

Conversation

ericniebler
Copy link
Owner

No description provided.

@ericniebler
Copy link
Owner Author

@cjdb I invite you to comment on this benchmark, in regards to #1337.

Copy link
Contributor

@cjdb cjdb left a comment

Choose a reason for hiding this comment

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

LGTM overall; thanks for looking into this.

auto palindrome_range_to(std::vector<std::string> const & words)
{
auto is_palindrome = [](auto const & word) {
return not ranges::empty(word) and ranges::equal(word, word | views::reverse);
Copy link
Contributor

Choose a reason for hiding this comment

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

It pains me to mention this, but you might like to grep for not, and, and or, since you did a massive overhal earlier in the year.

// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm cool with the code from #1337 being under the Boost licence, so long as it doesn't prevent me from also continuing to distribute it under Apache 2 with LLVM exception (IANAL but my understanding is that this is okay).

Copy link
Owner Author

Choose a reason for hiding this comment

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

BSL is "free for all uses, and you don't even need to include this license but you do have to include copyright." Speaking of which, this code is also yours so I'll add a copyright notice for you unless you say otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM (I use this code in classrooms).

words_.push_back("his");
words_.push_back("face");
words_.push_back("abba");
words_.push_back("toot");
Copy link
Contributor

Choose a reason for hiding this comment

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

I read in a dictionary of words from file, but this will make things easier, and apparently still highlights the issue.

for(auto _ : st)
{
auto words = ::palindrome_range_common(words_);
benchmark::DoNotOptimize(words.data());
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between benchmark::DoNotOptimize(words) and benchmark::DoNotOptimize(words.data())? I did the former.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not sure, but I think the latter is necessary for ClobberMemory to have any meaningful effects (if I'm reading it right).

{
auto words = ::palindrome_range_common(words_);
benchmark::DoNotOptimize(words.data());
benchmark::ClobberMemory();
Copy link
Contributor

Choose a reason for hiding this comment

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

I also forgot to clobber, but I suspect that would only make my times look better?

for(auto _ : st)
{
auto words = ::palindrome_range_to(words_);
benchmark::DoNotOptimize(words_.data());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
benchmark::DoNotOptimize(words_.data());
benchmark::DoNotOptimize(words.data());

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, s/\<words\>/result/g.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only comment that triggered "Request changes".

@ericniebler ericniebler merged commit c6ca561 into master Dec 5, 2019
@ericniebler ericniebler deleted the google-benchmark branch December 5, 2019 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants