Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chengm349 opened this issue Jun 7, 2024 · 6 comments

Comments

@chengm349
Copy link

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?

@dmah42
Copy link
Member

dmah42 commented Jun 7, 2024

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.

@chengm349
Copy link
Author

@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
Copy link
Author

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

@dmah42
Copy link
Member

dmah42 commented Jun 8, 2024

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.

@chengm349
Copy link
Author

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

@dmah42
Copy link
Member

dmah42 commented Jun 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants