benchmark icon indicating copy to clipboard operation
benchmark copied to clipboard

How to post my issue to https://groups.google.com/d/forum/benchmark-discuss

Open chengm349 opened this issue 1 year ago • 6 comments

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_ctor_dbl(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?

chengm349 avatar Jun 07 '24 06:06 chengm349

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 avatar Jun 07 '24 10:06 dmah42

@dmah42 Question 1: So my code of using the lib is correct? static void BM_decimal_ctor_dbl(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

chengm349 avatar Jun 08 '24 11:06 chengm349

I want to move similar questions https://groups.google.com/d/forum/benchmark-discuss, but I can't post any question there.

chengm349 avatar Jun 08 '24 11:06 chengm349

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.

dmah42 avatar Jun 08 '24 14:06 dmah42

I meant by using your MyClass impl, where is the assembly code?

chengm349 avatar Jun 09 '24 01:06 chengm349

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.

dmah42 avatar Jun 10 '24 09:06 dmah42