2 * Copyright 2016 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 <folly/Benchmark.h>
18 #include <folly/experimental/symbolizer/Dwarf.h>
19 #include <folly/portability/GFlags.h>
23 BENCHMARK(DwarfFindAddress, n) {
24 folly::BenchmarkSuspender suspender;
25 using namespace folly::symbolizer;
26 // NOTE: Using '/proc/self/exe' only works if the code for @dummy is
27 // statically linked into the binary.
28 ElfFile elf("/proc/self/exe");
31 for (size_t i = 0; i < n; i++) {
32 Dwarf::LocationInfo info;
33 dwarf.findAddress(uintptr_t(&dummy), info);
37 int main(int argc, char* argv[]) {
38 gflags::ParseCommandLineFlags(&argc, &argv, true);
39 google::InitGoogleLogging(argv[0]);
40 folly::runBenchmarksOnFlag();