Comment 41 for bug 1396654

Revision history for this message
Andrea Righi (arighi) wrote :

Tested the following on bionic:

$ cat main.cpp
#include <benchmark/benchmark.h>
#include <vector>

static __attribute__ ((noinline)) int my_really_big_function()
{
  for(size_t i = 0; i < 1000; ++i)
  {
    benchmark::DoNotOptimize(i % 5);
  }
  return 0;
}

static __attribute__ ((noinline)) void caller1()
{
  for(size_t i = 0; i < 1000; ++i)
  {
    benchmark::DoNotOptimize(my_really_big_function());
    benchmark::DoNotOptimize(i % 5);
  }
}

static __attribute__ ((noinline)) void myfun(benchmark::State& state)
{
  while(state.KeepRunning())
  {
    caller1();
  }
}

BENCHMARK(myfun);

BENCHMARK_MAIN();

$ clang++ main.cpp -o main -fno-omit-frame-pointer -O0 -lpthread -lbenchmark

$ perf record -g ./main

$ perf report -g 'graph,0.5,caller'

Result:

 - with linux-tools-common 4.15.0-46.49:

Samples: 3K of event 'cpu-clock', Event count (approx.): 757250000
  Children Self Command Shared Object Symbol
+ 99.67% 0.00% main libbenchmark.so.1.3.0 [.] 0x0000000000015b58
+ 99.67% 0.00% main main [.] _ZL5myfunRN9benchmark5StateE
+ 99.64% 0.17% main main [.] _ZL7caller1v
+ 99.50% 99.47% main main [.] _ZL22my_really_big_functionv
...

 - with linux-tools-common 4.15.0-47.50 (from -proposed):

Samples: 3K of event 'cpu-clock', Event count (approx.): 755000000
  Children Self Command Shared Object Symbol
+ 99.77% 0.00% main libbenchmark.so.1.3.0 [.] 0x0000000000015b58
+ 99.77% 0.00% main main [.] myfun
+ 99.70% 0.13% main main [.] caller1
+ 99.64% 99.64% main main [.] my_really_big_function
...

This problem seems fixed now.