C++ Weekly - Ep 70 - C++ IIFE in quick-bench.com

preview_player
Показать описание
☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟

T-SHIRTS AVAILABLE!

WANT MORE JASON?

SUPPORT THE CHANNEL

GET INVOLVED

JASON'S BOOKS

► C++23 Best Practices

► C++ Best Practices

JASON'S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1

► Object Lifetime Puzzlers Book 2

► Object Lifetime Puzzlers Book 3

► Copy and Reference Puzzlers Book 1

► Copy and Reference Puzzlers Book 2

► Copy and Reference Puzzlers Book 3

► OpCode Puzzlers Book 1


RECOMMENDED BOOKS

AWESOME PROJECTS

O'Reilly VIDEOS

Рекомендации по теме
Комментарии
Автор

I don't think "other" vs "0" has anything to do with small string optimization. "other" took longer because strlen (called in std::string's ctor) takes longer.

shakooosk
Автор

What about string_view and operator""sv?

MarekKnapek
Автор

Note: the website used for benchmarking seems to use the micro-benchmarking library google/benchmark. Using it in your own projects requires compiling it using CMake (what I could do without encountering any particular difficulty).

moandrez
Автор

I tried it even with string views on GCC 7.1 and I couldn't find a noticeable difference. I suppose it depends on implementation and context where it's used. The difference was in the range of 1-2 nanoseconds at most. I consider that to be noise.

From personal experience though, I noticed when I const things I actually get worse performance. Yeah, that was a WTF conclusion. Which is why I reduced my obsession with const-ing everything I don't modify.

dresnyd