C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fwd: Extension to runtime polymorphism proposed

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 02 Apr 2026 18:36:57 -0700
On Thursday, 2 April 2026 14:20:37 Pacific Daylight Time Muneem via Std-
Proposals wrote:
> benchmarks don't lie! Even if the assembly is the same size and looks
> similar, benchmarks show otherwise. Do benchmarking in the code that I
> showed using my proposal.

As Marcin said, benchmarks can lie... or at least be highly misleading.

You MUST read the assembly to verify that the compiler didn't do something
dumb, like realise that your code is doing nothing and remove the thing that
you're trying to benchmark. It's entirely possible that this is the case here
and that's why you're getting unreasonably low numbers for the cases other
than std::variant.

If the assembly looks similar, it should have similar performance too. If it
doesn't, run benchmark using CPU performance counters to see why they differ so
much and tell us what happened.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-04-03 01:36:59