1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 // Simple benchmarking facility. 17 #ifndef TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_ 18 #define TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_ 19 20 #include "benchmark/benchmark.h" // from @com_google_benchmark // IWYU pragma: export 21 #include "tensorflow/core/platform/platform.h" 22 23 // FIXME(vyng): Remove this. 24 // Background: During the benchmark-migration projects, all benchmarks were made 25 // to use "testing::benchmark::" prefix because that is what the internal 26 // Google benchmark library use. 27 namespace testing { 28 namespace benchmark { 29 using ::benchmark::State; // NOLINT 30 } // namespace benchmark 31 } // namespace testing 32 33 namespace tensorflow { 34 namespace testing { 35 RunBenchmarks()36inline void RunBenchmarks() { benchmark::RunSpecifiedBenchmarks(); } InitializeBenchmarks(int * argc,char ** argv)37inline void InitializeBenchmarks(int* argc, char** argv) { 38 benchmark::Initialize(argc, argv); 39 } 40 41 template <class T> DoNotOptimize(const T & var)42void DoNotOptimize(const T& var) { 43 ::benchmark::DoNotOptimize(var); 44 } 45 } // namespace testing 46 } // namespace tensorflow 47 48 #endif // TENSORFLOW_CORE_PLATFORM_TEST_BENCHMARK_H_ 49