Repository navigation
Conversation
|
Why? |
|
Hi @LebedevRI. Currently, calling This change makes |
Ok, but why are you doing that? That function is only meant to be called once.
|
|
I came across this while running benchmarks in a Jupyter notebook. Since both runs share the same kernel, the JSON report for the second script still had the executable name from the first script. I initially changed just the Python binding but noticed Rust had a similar workaround, so I expanded the change into If you'd prefer, I can narrow this to just the Python binding |
|
why do you need to reinitialize across the notebook? what functionality do you lose by initializing once and then registering/running different benchmarks in each cell? |
In
src/benchmark.cc, updateParseCommandLineFlagsto own and refresh a copy ofargv[0]on each call, ensuringBenchmarkReporter::Context::executable_namedoesn't depend on caller-owned storage. Sincebenchmark::InitializecallsParseCommandLineFlags, remove the redundant copies from the Python and Rust bindings (bindings/python/google_benchmark/benchmark.ccandbindings/rust/src/rust_api.cc).Tests:
benchmark::Initializecalls, input mutation, and buffer destruction.context.executableafter repeatedgoogle_benchmark.initializecalls.python -I bindings/python/initialization_test.pyin CI.Codex reviewed and assisted with writing tests.