diff options
author | Robert Guo <robert.guo@10gen.com> | 2018-02-13 16:21:44 -0500 |
---|---|---|
committer | Robert Guo <robert.guo@10gen.com> | 2018-02-14 18:07:21 -0500 |
commit | 518d8e0d3cd756eb1c10b6c0aa1f9f9707159f87 (patch) | |
tree | 33cb3270809c41cbf197504172b9e2c7ad52d777 | |
parent | c927a61213f5e1e80d7535b6cb1a16f23a6d0b98 (diff) | |
download | mongo-518d8e0d3cd756eb1c10b6c0aa1f9f9707159f87.tar.gz |
SERVER-33200 add entry point for Benchmark tests
-rw-r--r-- | site_scons/site_tools/mongo_benchmark.py | 1 | ||||
-rw-r--r-- | src/mongo/unittest/SConscript | 12 | ||||
-rw-r--r-- | src/mongo/unittest/benchmark_main.cpp | 49 | ||||
-rw-r--r-- | src/mongo/unittest/benchmark_test.cpp | 3 |
4 files changed, 62 insertions, 3 deletions
diff --git a/site_scons/site_tools/mongo_benchmark.py b/site_scons/site_tools/mongo_benchmark.py index bd3c09f9f3c..8470a9bfdbf 100644 --- a/site_scons/site_tools/mongo_benchmark.py +++ b/site_scons/site_tools/mongo_benchmark.py @@ -28,6 +28,7 @@ def build_benchmark(env, target, source, **kwargs): bmEnv.Append(LIBS=["ShLwApi.lib"]) libdeps = kwargs.get('LIBDEPS', []) + libdeps.append('$BUILD_DIR/mongo/unittest/benchmark_main') libdeps.append('$BUILD_DIR/third_party/shim_benchmark') kwargs['LIBDEPS'] = libdeps diff --git a/src/mongo/unittest/SConscript b/src/mongo/unittest/SConscript index aeb99938cc5..60315dcc5bd 100644 --- a/src/mongo/unittest/SConscript +++ b/src/mongo/unittest/SConscript @@ -34,6 +34,18 @@ env.Library(target="integration_test_main", ], ) +bmEnv = env.Clone() +bmEnv.InjectThirdPartyIncludePaths(libraries=['benchmark']) +bmEnv.Library( + target="benchmark_main", + source=[ + 'benchmark_main.cpp' + ], + LIBDEPS=[ + '$BUILD_DIR/mongo/base', + ], +) + env.CppUnitTest('unittest_test', 'unittest_test.cpp') env.CppUnitTest('fixture_test', 'fixture_test.cpp') env.CppUnitTest('temp_dir_test', 'temp_dir_test.cpp') diff --git a/src/mongo/unittest/benchmark_main.cpp b/src/mongo/unittest/benchmark_main.cpp new file mode 100644 index 00000000000..a992ddb06bf --- /dev/null +++ b/src/mongo/unittest/benchmark_main.cpp @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects + * for all of the code used other than as permitted herein. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. If you + * delete this exception statement from all source files in the program, + * then also delete it in the license file. + */ + +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault + +#include "mongo/platform/basic.h" + +#include <benchmark/benchmark.h> + +#include "mongo/base/initializer.h" +#include "mongo/util/signal_handlers_synchronous.h" + + +int main(int argc, char** argv, char** envp) { + ::mongo::clearSignalMask(); + ::mongo::setupSynchronousSignalHandlers(); + ::mongo::runGlobalInitializersOrDie(argc, argv, envp); + + // Copied from the BENCHMARK_MAIN macro. + ::benchmark::Initialize(&argc, argv); + if (::benchmark::ReportUnrecognizedArguments(argc, argv)) + return 1; + ::benchmark::RunSpecifiedBenchmarks(); +} diff --git a/src/mongo/unittest/benchmark_test.cpp b/src/mongo/unittest/benchmark_test.cpp index 4949e5df668..18e0466cbb5 100644 --- a/src/mongo/unittest/benchmark_test.cpp +++ b/src/mongo/unittest/benchmark_test.cpp @@ -48,6 +48,3 @@ BENCHMARK(BM_empty); BENCHMARK(BM_empty)->ThreadPerCpu(); } // namespace - -// This function executes previously registered benchmarks. -BENCHMARK_MAIN(); |