I was trying the google benchmark example from CppCon Chandler Carruth and I have completely different results (for vector reserve) on OsX and PC(running linux), and I am not sure why?
https://github.com/Horki/benchtest
1 2 3 4 5 6 7
|
static void bench_reserve(benchmark::State &state) {
while (state.KeepRunning()) {
vector<int> v;
v.reserve(1);
}
}
BENCHMARK(bench_reserve);
| |
Os X
Run on (8 X 2200 MHz CPU s)
CPU Caches:
L1 Data 32K (x4)
L1 Instruction 32K (x4)
L2 Unified 262K (x4)
L3 Unified 6291K (x1)
-------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------
bench_create 0 ns 0 ns 1000000000
bench_reserve 0 ns 0 ns 1000000000
bench_push_back 2 ns 2 ns 355207340
Edit: updated g benchmark on Os X, new result
Run on (8 X 2200 MHz CPU s)
CPU Caches:
L1 Data 32K (x4)
L1 Instruction 32K (x4)
L2 Unified 262K (x4)
L3 Unified 6291K (x1)
Load Average: 1.38, 1.73, 1.70
----------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------
bench_create 0.308 ns 0.308 ns 1000000000
bench_reserve 0.302 ns 0.302 ns 1000000000
bench_push_back 2.05 ns 2.05 ns 343612248
Arch Linux
Run on (8 X 4000 MHz CPU s)
CPU Caches:
L1 Data 32K (x4)
L1 Instruction 32K (x4)
L2 Unified 256K (x4)
L3 Unified 8192K (x1)
Load Average: 0.05, 0.12, 0.15
----------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------
bench_create 0.266 ns 0.266 ns 1000000000
bench_reserve 9.59 ns 9.59 ns 69819729
bench_push_back 9.58 ns 9.58 ns 73438758