Open chengm349 opened 3 months ago
depending on what you're doing the compiler just might be that good.
https://godbolt.org/z/rT6E3bf9b shows that the compiler reduces the code quite a bit.
@dmah42 Question 1: So my code of using the lib is correct? static void BM_decimal_ctordbl(benchmark::State& state) { for (auto : state) { const MyClass d{123.67}; benchmark::DoNotOptimize(&d); } }
Question 2: which assembly lines are for the MyClass ctor? These? push %rbp push %r14 push %rbx sub $0x10,%rsp mov %rdi,%rbx mov 0x1c(%rdi),%ebp mov 0x10(%rdi),%r14
I want to move similar questions https://groups.google.com/d/forum/benchmark-discuss, but I can't post any question there.
I can't identify the assembly without seeing what your class does. but godbolt does a good job of mapping the code to the assembly so you should be able to see it there.
I meant by using your MyClass impl, where is the assembly code?
ah, line 30 ( mov %rax,0x8(%rsp) )
but there's also a couple of lines moving the value to the stack: movabs $0x40263dcc937ad959,%rax lea 0x8(%rsp),%rcx
you can see this in the tool with the color coding.
I joined the group but I can't post my question there. Please guide.
I have a class MyClass and I want to measure its ctor performance like this:
static void BM_decimal_ctordbl(benchmark::State& state) { for (auto : state) { const MyClass d{123.67}; benchmark::DoNotOptimize(d); } }
2024-06-07T13:50:06+08:00 Running ./AS7_DEC/decimalBM Run on (12 X 2194.84 MHz CPU s) CPU Caches: L1 Data 48 KiB (x12) L1 Instruction 32 KiB (x12) L2 Unified 1280 KiB (x12) L3 Unified 49152 KiB (x2) Load Average: 0.10, 0.17, 0.18
Benchmark Time CPU Iterations
BM_decimal_ctor_dbl 0.364 ns 0.364 ns 1937088812
I doubted my class performance too good. Is my benchmark code correct?