diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-16 16:34:08 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-16 16:34:08 +0100 |
commit | c1002936abe28230ab43a960d164cd05d51f69ec (patch) | |
tree | f3ebdf68b94561ac991049e2a22cd241ca4be41d | |
parent | Fix-up all the clang-tidy warnings (diff) | |
download | netfs-gitfs-0.2.4.tar.bz2 netfs-gitfs-0.2.4.tar.xz netfs-gitfs-0.2.4.zip |
Add a perf test of key functionsHEADnetfs-gitfs-0.2.4main
-rw-r--r-- | unittests/Jamfile.jam | 4 | ||||
-rw-r--r-- | unittests/perf.cpp | 50 |
2 files changed, 53 insertions, 1 deletions
diff --git a/unittests/Jamfile.jam b/unittests/Jamfile.jam index ad6f108..b27d67a 100644 --- a/unittests/Jamfile.jam +++ b/unittests/Jamfile.jam @@ -1,5 +1,6 @@ lib boost_utf : : <name>boost_unit_test_framework ; lib dryice : : : : <library>..//icetray ; +lib benchmark ; path-constant gitdir : ../.git ; @@ -23,4 +24,5 @@ lib common : run config.cpp : : : <library>common ; run core.cpp : : : <library>common ; run service.cpp : : : <library>common ; - +explicit perf ; +run perf.cpp : : : <library>common <library>benchmark ; diff --git a/unittests/perf.cpp b/unittests/perf.cpp new file mode 100644 index 0000000..4e7155c --- /dev/null +++ b/unittests/perf.cpp @@ -0,0 +1,50 @@ +#include "mockDefs.h" +#include <benchmark/benchmark.h> +#include <volume.h> + +using namespace GitFS; +using namespace GitFS::Test; + +const Service globalService; + +struct BenchmarkClient : public benchmark::Fixture { + NetFS::ReqEnv re {"root", "root"}; + std::string root {"/"}, deep {"/unittests/fixtures/executable"}; +}; + +BENCHMARK_F(BenchmarkClient, statfs_root)(benchmark::State & state) +{ + VolumeClient v; + for (auto _ : state) { + benchmark::DoNotOptimize(v.v->statfs(re, root)); + } +} + +BENCHMARK_F(BenchmarkClient, getattr_root)(benchmark::State & state) +{ + VolumeClient v; + for (auto _ : state) { + benchmark::DoNotOptimize(v.v->getattr(re, root)); + } +} + +BENCHMARK_F(BenchmarkClient, getattr_deep)(benchmark::State & state) +{ + VolumeClient v; + for (auto _ : state) { + benchmark::DoNotOptimize(v.v->getattr(re, root)); + } +} + +BENCHMARK_F(BenchmarkClient, listdir_src)(benchmark::State & state) +{ + VolumeClient v; + const std::string src {"/src"}; + auto dir = v.v->opendir(re, src); + for (auto _ : state) { + benchmark::DoNotOptimize(dir->listdir()); + } + dir->close(); +} + +BENCHMARK_MAIN(); |