2
* Copyright (c) 2016-present, Facebook, Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
#include "benchmark/benchmark.h"
19
#include <c10/util/Logging.h>
22
#define NOINLINE __attribute__((noinline))
27
NOINLINE int call(int id) {
28
C10_LOG_API_USAGE_ONCE("bla");
32
NOINLINE int call_no_logging(int id) {
36
static void BM_APILogging(benchmark::State& state) {
38
while (state.KeepRunning()) {
39
for (int i = 0; i < 1000; ++i) {
43
benchmark::DoNotOptimize(id);
45
BENCHMARK(BM_APILogging);
47
static void BM_NoAPILogging(benchmark::State& state) {
49
while (state.KeepRunning()) {
50
for (int i = 0; i < 1000; ++i) {
51
id += 1 + call_no_logging(id);
54
benchmark::DoNotOptimize(id);
56
BENCHMARK(BM_NoAPILogging);