Skip to content

Instantly share code, notes, and snippets.

@DenisYaroshevskiy
Last active April 26, 2020 00:00
Show Gist options
  • Save DenisYaroshevskiy/4546197583a4a5abd485dea5397abaa4 to your computer and use it in GitHub Desktop.
Save DenisYaroshevskiy/4546197583a4a5abd485dea5397abaa4 to your computer and use it in GitHub Desktop.
For a discussion on stack overflow
Different times for different alignments: best is padding is 6 bytes, worth when it's 50 bytes
===============================================================================================================
sudo perf stat -e LSD.UOPS,UOPS_ISSUED.ANY,branches,branch-misses ./src/bench_runnable2/remove "--benchmark_filter=.*size:10000/type:int/algorithm:std::remove/percentage:50/padding:50$"
2020-04-26 00:59:16
Running ./src/bench_runnable2/remove
Run on (8 X 4900 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x8)
L1 Instruction 32 KiB (x8)
L2 Unified 256 KiB (x8)
L3 Unified 12288 KiB (x1)
Load Average: 0.21, 0.12, 0.08
-----------------------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------------------------------------
/name:remove 0s/size:10000/type:int/algorithm:std::remove/percentage:50/padding:50 7211 ns 7211 ns 97153
Performance counter stats for './src/bench_runnable2/remove --benchmark_filter=.*size:10000/type:int/algorithm:std::remove/percentage:50/padding:50$':
0 LSD.UOPS
69,442,388,854 UOPS_ISSUED.ANY
11,826,143,943 branches
127,890,842 branch-misses # 1.08% of all branches
5.302266596 seconds time elapsed
5.268550000 seconds user
0.016013000 seconds sys
sudo perf stat -e LSD.UOPS,UOPS_ISSUED.ANY,branches,branch-misses ./src/bench_runnable2/remove "--benchmark_filter=.*size:10000/type:int/algorithm:std::remove/percentage:50/padding:6$"
2020-04-26 00:59:29
Running ./src/bench_runnable2/remove
Run on (8 X 4900 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x8)
L1 Instruction 32 KiB (x8)
L2 Unified 256 KiB (x8)
L3 Unified 12288 KiB (x1)
Load Average: 0.24, 0.13, 0.08
----------------------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
----------------------------------------------------------------------------------------------------------------------------
/name:remove 0s/size:10000/type:int/algorithm:std::remove/percentage:50/padding:6 1460 ns 1460 ns 475866
Performance counter stats for './src/bench_runnable2/remove --benchmark_filter=.*size:10000/type:int/algorithm:std::remove/percentage:50/padding:6$':
0 LSD.UOPS
74,238,458,573 UOPS_ISSUED.ANY
14,824,364,356 branches
19,807,323 branch-misses # 0.13% of all branches
5.371986435 seconds time elapsed
5.333160000 seconds user
0.020004000 seconds sys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment