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

Allow specifying number of iterations via --benchmark_min_time. #1525

Merged
merged 35 commits into from
Feb 7, 2023

Conversation

oontvoo
Copy link
Member

@oontvoo oontvoo commented Jan 11, 2023

Make the flag accept two new suffixes:

  • x: number of iterations
  • s: minimum number of seconds.

This matches the internal benchmark API.

Make the flag accept two new suffixes:
 + <integer>x: number of iterations
 + <floag>s: minimum number of seconds.

This matches the internal benchmark API.
@oontvoo
Copy link
Member Author

oontvoo commented Jan 11, 2023

@dmah42 Let me know if we should rename the flag in this patch too? Thanks!

@dmah42
Copy link
Member

dmah42 commented Jan 11, 2023

aside from the broken build, this is also a breaking change. before it's merged we should do a release and then release right after it's merged with clear documentation about the behaviour change.

i haven't checked the code yet.. but does it also accept the old behaviour (ie if the "s" is missing")?

@oontvoo
Copy link
Member Author

oontvoo commented Jan 11, 2023

but does it also accept the old behaviour (ie if the "s" is missing")?

Yes - if suffixes are omitted, then we'd assume it's the number of seconds for backward compat (But we do issue a warning just to encourage users to use the new format)

src/benchmark.cc Outdated Show resolved Hide resolved
src/benchmark.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
test/BUILD Show resolved Hide resolved
@oontvoo
Copy link
Member Author

oontvoo commented Jan 11, 2023

adding tests - please hold off on the review. Will ping when ready. Thanks!

src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
src/benchmark_runner.cc Outdated Show resolved Hide resolved
@oontvoo
Copy link
Member Author

oontvoo commented Jan 19, 2023

Hi @LebedevRI, any thought on this? Thanks!

bool has_suffix = value.back() == 's';
if (!has_suffix) {
BM_VLOG(0) << "Value passed to --benchmark_min_time should have a suffix. "
"Eg., `30s` for 30-seconds.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes it look like other suffixes (ms?) are supported

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we could extend the suffixes support later - but for the first iteration, let's keep it simple. (And I'd like to get the interface in place first)

src/benchmark_runner.cc Outdated Show resolved Hide resolved
@oontvoo
Copy link
Member Author

oontvoo commented Jan 20, 2023

Hi, if there's no further objection, can we please get this rolling? Thanks!

dmah42
dmah42 previously approved these changes Jan 20, 2023
@dmah42
Copy link
Member

dmah42 commented Jan 20, 2023

i'd like @LebedevRI to approve too


// After a successfull parse, p_end should point to the suffix 's'
// or the end of the string, if the suffix was omitted.
BM_CHECK(errno == 0 && p_end != nullptr &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check is present in release builds, right?

Copy link
Member

Choose a reason for hiding this comment

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

no, it acts like assert and is disabled in NDEBUG builds

@LebedevRI
Copy link
Collaborator

Consider this rubber-stamped.

@LebedevRI
Copy link
Collaborator

(also, what about warm-up option, should it also be affected?)

@oontvoo
Copy link
Member Author

oontvoo commented Jan 23, 2023

(also, what about warm-up option, should it also be affected?)

No, this will not affect the warm-up option.
(We could expand that flag, if it's useful? l)

@dmah42
Copy link
Member

dmah42 commented Jan 24, 2023

some valid linker errors: min_time_parse_gtest.cc:(.text+0x6ba): undefined reference to benchmark::internal::ParseBenchMinTime(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'`

@oontvoo
Copy link
Member Author

oontvoo commented Jan 24, 2023

some valid linker errors: min_time_parse_gtest.cc:(.text+0x6ba): undefined reference to benchmark::internal::ParseBenchMinTime(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'`

Hmm, any idea why the definition is not seen?

(The function is defined in benchmark_runner.cc - and moreover,t he same code built in other configurations .... what's difference about these "shared" runs? 🤔 )

@oontvoo
Copy link
Member Author

oontvoo commented Jan 24, 2023

some valid linker errors: min_time_parse_gtest.cc:(.text+0x6ba): undefined reference to benchmark::internal::ParseBenchMinTime(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'`

Hmm, any idea why the definition is not seen?

(The function is defined in benchmark_runner.cc - and moreover,t he same code built in other configurations .... what's difference about these "shared" runs? thinking )

Ok - now the tests all PASSED in Debug builds but FAILED in Release builds (due to "failed to die").
I must be missing something here but the #ifndef NDEBUG should have prevented the tests from running in Release mode - why are they still running? (and hence failing?)

@oontvoo
Copy link
Member Author

oontvoo commented Jan 24, 2023

some valid linker errors: min_time_parse_gtest.cc:(.text+0x6ba): undefined reference to benchmark::internal::ParseBenchMinTime(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'`

Hmm, any idea why the definition is not seen?
(The function is defined in benchmark_runner.cc - and moreover,t he same code built in other configurations .... what's difference about these "shared" runs? thinking )

Ok - now the tests all PASSED in Debug builds but FAILED in Release builds (due to "failed to die"). I must be missing something here but the #ifndef NDEBUG should have prevented the tests from running in Release mode - why are they still running? (and hence failing?)

Ah, found it! TEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS is the needed guard

@dmah42
Copy link
Member

dmah42 commented Feb 6, 2023

any more comments here before we rebase and squash and merge?

@LebedevRI
Copy link
Collaborator

Consider this rubber-stamped.

@dmah42 dmah42 merged commit 6cf7725 into google:main Feb 7, 2023
@dmah42
Copy link
Member

dmah42 commented Feb 7, 2023

wonderful. thank you.

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.

4 participants