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

Bind benchmark builder to Python #1040

Merged
merged 7 commits into from
Sep 11, 2020
Merged

Bind benchmark builder to Python #1040

merged 7 commits into from
Sep 11, 2020

Conversation

AntoinePrv
Copy link
Contributor

@AntoinePrv AntoinePrv commented Sep 9, 2020

The following PR Close #1038

  • Bind TimeUnit and BigO
  • Bind internal::Benchmark
  • Modify RegisterBenchmark to return the benchmark object
  • Bind builder methods from internal::Benchmark
  • Add a Python decorator option to use the Benchmark options.

Example

@benchmark.register
@benchmark.option.range_multiplier(2)
@benchmark.option.range(1 << 10, 1 << 18)
@benchmark.option.complexity(benchmark.oN)
def computing_complexity(state):
    while state:
        sum(range(state.range(0)))
    state.complexity_n = state.range(0)

Todo

@AntoinePrv AntoinePrv marked this pull request as draft September 9, 2020 19:48
@google-cla google-cla bot added the cla: yes label Sep 9, 2020
@AntoinePrv
Copy link
Contributor Author

Ok, so indeed I cannot run Python in multiple thread without acquiring the GIL.
I tried to register the threads and acquire the GIL, but it now deadlocks.
Probably due to

In a multithreaded test (benchmark invoked by multiple threads simultaneously), it is guaranteed that none of the threads will start until all have reached the start of the benchmark loop

Anyways, seems to be out of scope for this issue

@dmah42
Copy link
Member

dmah42 commented Sep 10, 2020

We should probably update the __version__ in init.py too with this change.

@dmah42 dmah42 added enhancement next-release PRs or Issues that should be included in the next release labels Sep 10, 2020
@AntoinePrv
Copy link
Contributor Author

I rebased on master and bumped version to 0.2.0. I also fixed an indentation bug that arose in the setup.py.

@AntoinePrv AntoinePrv marked this pull request as ready for review September 10, 2020 14:57

self.spawn(bazel_argv)
self.spawn(bazel_argv)
Copy link
Member

Choose a reason for hiding this comment

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

i fixed this same issue in #1041 :)

well spotted!

@dmah42
Copy link
Member

dmah42 commented Sep 10, 2020

LGTM but i'll wait a while in case there's any issues raised.

@dmah42 dmah42 merged commit 73d4d5e into google:master Sep 11, 2020
@AntoinePrv AntoinePrv deleted the bind-benchmark branch September 11, 2020 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes enhancement next-release PRs or Issues that should be included in the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR][Python] Bind Benchmark methods / builder pattern
3 participants