proxygen
DwarfBenchmark.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #include <folly/Benchmark.h>
20 
21 void dummy() {}
22 
23 namespace {
24 
25 using namespace folly::symbolizer;
26 
27 void run(Dwarf::LocationInfoMode mode, size_t n) {
28  folly::BenchmarkSuspender suspender;
29  // NOTE: Using '/proc/self/exe' only works if the code for @dummy is
30  // statically linked into the binary.
31  ElfFile elf("/proc/self/exe");
32  Dwarf dwarf(&elf);
33  suspender.dismiss();
34  for (size_t i = 0; i < n; i++) {
36  dwarf.findAddress(uintptr_t(&dummy), info, mode);
37  }
38 }
39 
40 } // namespace
41 
42 BENCHMARK(DwarfFindAddressFast, n) {
44 }
45 
46 BENCHMARK(DwarfFindAddressFull, n) {
48 }
49 
50 int main(int argc, char* argv[]) {
51  gflags::ParseCommandLineFlags(&argc, &argv, true);
52  google::InitGoogleLogging(argv[0]);
54  return 0;
55 }
def info()
Definition: deadlock.py:447
bool findAddress(uintptr_t address, LocationInfo &info, LocationInfoMode mode) const
Definition: Dwarf.cpp:575
folly::Optional< PskKeyExchangeMode > mode
char ** argv
static void run(EventBaseManager *ebm, EventBase *eb, folly::Baton<> *stop, const StringPiece &name)
int main(int argc, char *argv[])
void dummy()
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
Definition: Benchmark.cpp:84
bool runBenchmarksOnFlag()
Definition: Benchmark.h:48