mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
libstore-tests: Split bench-main into a separate file
This makes it easier to add new benchmarks.
This commit is contained in:
parent
b8301b2c25
commit
b2b2f2dc53
3 changed files with 20 additions and 14 deletions
14
src/libstore-tests/bench-main.cc
Normal file
14
src/libstore-tests/bench-main.cc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <benchmark/benchmark.h>
|
||||
#include "nix/store/globals.hh"
|
||||
|
||||
// Custom main to initialize Nix before running benchmarks
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// Initialize libstore
|
||||
nix::initLibStore(false);
|
||||
|
||||
// Initialize and run benchmarks
|
||||
::benchmark::Initialize(&argc, argv);
|
||||
::benchmark::RunSpecifiedBenchmarks();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
#include "nix/store/store-api.hh"
|
||||
#include "nix/util/experimental-features.hh"
|
||||
#include "nix/store/store-open.hh"
|
||||
#include "nix/store/globals.hh"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
|
@ -31,15 +30,3 @@ static void BM_ParseRealDerivationFile(benchmark::State & state, const std::stri
|
|||
// Register benchmarks for actual test derivation files if they exist
|
||||
BENCHMARK_CAPTURE(BM_ParseRealDerivationFile, hello, std::string(NIX_UNIT_TEST_DATA) + "/derivation/hello.drv");
|
||||
BENCHMARK_CAPTURE(BM_ParseRealDerivationFile, firefox, std::string(NIX_UNIT_TEST_DATA) + "/derivation/firefox.drv");
|
||||
|
||||
// Custom main to initialize Nix before running benchmarks
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// Initialize libstore
|
||||
nix::initLibStore(false);
|
||||
|
||||
// Initialize and run benchmarks
|
||||
::benchmark::Initialize(&argc, argv);
|
||||
::benchmark::RunSpecifiedBenchmarks();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,9 +110,14 @@ test(
|
|||
if get_option('benchmarks')
|
||||
gbenchmark = dependency('benchmark', required : true)
|
||||
|
||||
benchmark_sources = files(
|
||||
'bench-main.cc',
|
||||
'derivation-parser-bench.cc',
|
||||
)
|
||||
|
||||
benchmark_exe = executable(
|
||||
'nix-store-benchmarks',
|
||||
'derivation-parser-bench.cc',
|
||||
benchmark_sources,
|
||||
config_priv_h,
|
||||
dependencies : deps_private_subproject + deps_private + deps_other + [gbenchmark],
|
||||
include_directories : include_dirs,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue