-
Notifications
You must be signed in to change notification settings - Fork 1.7k
handle fixture construction after static initialization: rev1 #512
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
Conversation
✅ Build benchmark 947 completed (commit b122cfb5ec by @lijinpei) |
namespace internal { | ||
// Take ownership of the pointer and register the benchmark. Return the | ||
// registered benchmark. | ||
Benchmark* RegisterBenchmarkInternal(Benchmark*); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this now under HAS_CXX11? I don't think it was before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is only needed if you use lambda benchmarks, function and fixture benchmarks are registered using the non-internal RegisterBenchmark().
return static_cast<int>(args_.front().size()); | ||
} | ||
|
||
void Benchmark::Init() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be in benchmark.cc, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All Benchmakr:: member functions are already in benchmark_register.cc, maybe we shall use a seperate commit to move them to benchmark.cc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh. yeah, probably move benchmark member functions to benchmark.cc and the stuff there to benchmark_main.cc or something.
src/benchmark_register.cc
Outdated
void FunctionBenchmark::Run(State& st) { func_(st); } | ||
// The class used to hold all Benchmarks created from static function. | ||
// (ie those created using the BENCHMARK(...) macros. | ||
class FunctionBenchmark : public Benchmark { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd be quite happy if these could be move out to their own header/source files (in src/).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, maybe I shall also move benchmark's member function definitions to benchmark.cc?
src/benchmark_register.cc
Outdated
|
||
internal::Benchmark* RegisterBenchmark(const char* name, internal::Function* func) { | ||
auto* p_benchmark = new internal::FunctionBenchmark(name, func); | ||
internal::BenchmarkFamilies::GetInstance()->AddBenchmark(std::unique_ptr<internal::Benchmark>(p_benchmark)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line length should be <= 80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
src/benchmark_register.cc
Outdated
|
||
Benchmark* RegisterBenchmark(const char *name, FixtureCreator* creator) { | ||
auto* p_benchmark = new FixtureBenchmark(name, creator); | ||
internal::BenchmarkFamilies::GetInstance()->AddBenchmark(std::unique_ptr<internal::Benchmark>(p_benchmark)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
} | ||
} | ||
|
||
int main(int argc, char **argv) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can use googletest for this instead of asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of the existing 35 testcases, only one(statistics_test) uses gtest. I add two testcases which does essentially the same thing, fixture_init_test.cpp doesn't use gtest while fixture_init_gtest.cpp does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this file necessary any more?
gtest is a new addition so we're just starting to move testing over to it. you're ahead of the curve :)
src/benchmark_register.cc
Outdated
Function* func_; | ||
}; | ||
|
||
//=============================================================================// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to mention it, all those comments are 81 characters width(not including the newline)
❌ Build benchmark 950 failed (commit ca7b0cccaf by @lijinpei) |
❌ Build benchmark 951 failed (commit 690b2a4035 by @lijinpei) |
✅ Build benchmark 952 completed (commit 529fc8788c by @lijinpei) |
virtual void BenchmarkCase(State&) = 0; | ||
}; | ||
|
||
namespace internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be put inside one of the existing internal namespaces instead of adding another block? at some point i tried to clean these blocks up.. it'd be nice to not make it messier.
❌ Build benchmark 953 failed (commit 7cd3f6b4a0 by @lijinpei) |
@lijinpei When you want to update a PR, please use the same branch and PR on github -- don't create new ones every time. You can either squash the old commits and force-push yourself, or you can simply push the new commits. When we merge the PR we'll squash the commits into a single one anyway. |
#include "benchmark_api_internal.h" | ||
|
||
namespace { | ||
using namespace benchmark; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just put the unnamed namespace inside benchmark::internal
instead of adding using
statements.
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
benchmark::Initialize(&argc, argv); | ||
return RUN_ALL_TESTS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test LGTM. Thanks.
504356b
to
df045ff
Compare
❌ Build benchmark 955 failed (commit d9940082d3 by @lijinpei) |
❌ Build benchmark 956 failed (commit a7d37aac99 by @lijinpei) |
I can revert to the version which doesn't change the header file very much if you don't want to merge the newest change. |
it would be nice to keep the PR focused. so one PR to handle the issue here, and another to clean up the header would be most appreciated. |
f8ed087
to
05baa30
Compare
❌ Build benchmark 962 failed (commit c7e2ac7617 by @lijinpei) |
❌ Build benchmark 963 failed (commit d64de82c6f by @lijinpei) |
23836c6
to
c88f257
Compare
❌ Build benchmark 966 failed (commit 0b6085ebd0 by @lijinpei) |
❌ Build benchmark 967 failed (commit 2b1d502e05 by @lijinpei) |
Are you still looking in to this, @lijinpei ? |
❌ Build benchmark 1302 failed (commit bbce1f06c3 by @lijinpei) |
I can re-start to work on this. |
I'm going to close this as it appears abandoned. Please feel free to try again. |
a revision of #511 and #505