Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
c++ source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
6502-c++ 11.1.0
ARM GCC 10.2.0
ARM GCC 10.3.0
ARM GCC 10.4.0
ARM GCC 10.5.0
ARM GCC 11.1.0
ARM GCC 11.2.0
ARM GCC 11.3.0
ARM GCC 11.4.0
ARM GCC 12.1.0
ARM GCC 12.2.0
ARM GCC 12.3.0
ARM GCC 12.4.0
ARM GCC 13.1.0
ARM GCC 13.2.0
ARM GCC 13.2.0 (unknown-eabi)
ARM GCC 13.3.0
ARM GCC 13.3.0 (unknown-eabi)
ARM GCC 14.1.0
ARM GCC 14.1.0 (unknown-eabi)
ARM GCC 14.2.0
ARM GCC 14.2.0 (unknown-eabi)
ARM GCC 4.5.4
ARM GCC 4.6.4
ARM GCC 5.4
ARM GCC 6.3.0
ARM GCC 6.4.0
ARM GCC 7.3.0
ARM GCC 7.5.0
ARM GCC 8.2.0
ARM GCC 8.5.0
ARM GCC 9.3.0
ARM GCC 9.4.0
ARM GCC 9.5.0
ARM GCC trunk
ARM gcc 10.2.1 (none)
ARM gcc 10.3.1 (2021.07 none)
ARM gcc 10.3.1 (2021.10 none)
ARM gcc 11.2.1 (none)
ARM gcc 5.4.1 (none)
ARM gcc 7.2.1 (none)
ARM gcc 8.2 (WinCE)
ARM gcc 8.3.1 (none)
ARM gcc 9.2.1 (none)
ARM msvc v19.0 (WINE)
ARM msvc v19.10 (WINE)
ARM msvc v19.14 (WINE)
ARM64 Morello gcc 10.1 Alpha 2
ARM64 gcc 10.2
ARM64 gcc 10.3
ARM64 gcc 10.4
ARM64 gcc 10.5.0
ARM64 gcc 11.1
ARM64 gcc 11.2
ARM64 gcc 11.3
ARM64 gcc 11.4.0
ARM64 gcc 12.1
ARM64 gcc 12.2.0
ARM64 gcc 12.3.0
ARM64 gcc 12.4.0
ARM64 gcc 13.1.0
ARM64 gcc 13.2.0
ARM64 gcc 13.3.0
ARM64 gcc 14.1.0
ARM64 gcc 14.2.0
ARM64 gcc 4.9.4
ARM64 gcc 5.4
ARM64 gcc 5.5.0
ARM64 gcc 6.3
ARM64 gcc 6.4
ARM64 gcc 7.3
ARM64 gcc 7.5
ARM64 gcc 8.2
ARM64 gcc 8.5
ARM64 gcc 9.3
ARM64 gcc 9.4
ARM64 gcc 9.5
ARM64 gcc trunk
ARM64 msvc v19.14 (WINE)
AVR gcc 10.3.0
AVR gcc 11.1.0
AVR gcc 12.1.0
AVR gcc 12.2.0
AVR gcc 12.3.0
AVR gcc 12.4.0
AVR gcc 13.1.0
AVR gcc 13.2.0
AVR gcc 13.3.0
AVR gcc 14.1.0
AVR gcc 14.2.0
AVR gcc 4.5.4
AVR gcc 4.6.4
AVR gcc 5.4.0
AVR gcc 9.2.0
AVR gcc 9.3.0
Arduino Mega (1.8.9)
Arduino Uno (1.8.9)
BPF clang (trunk)
BPF clang 13.0.0
BPF clang 14.0.0
BPF clang 15.0.0
BPF clang 16.0.0
BPF clang 17.0.1
BPF clang 18.1.0
BPF clang 19.1.0
EDG (experimental reflection)
EDG 6.5
EDG 6.5 (GNU mode gcc 13)
EDG 6.6
EDG 6.6 (GNU mode gcc 13)
FRC 2019
FRC 2020
FRC 2023
HPPA gcc 14.2.0
KVX ACB 4.1.0 (GCC 7.5.0)
KVX ACB 4.1.0-cd1 (GCC 7.5.0)
KVX ACB 4.10.0 (GCC 10.3.1)
KVX ACB 4.11.1 (GCC 10.3.1)
KVX ACB 4.12.0 (GCC 11.3.0)
KVX ACB 4.2.0 (GCC 7.5.0)
KVX ACB 4.3.0 (GCC 7.5.0)
KVX ACB 4.4.0 (GCC 7.5.0)
KVX ACB 4.6.0 (GCC 9.4.1)
KVX ACB 4.8.0 (GCC 9.4.1)
KVX ACB 4.9.0 (GCC 9.4.1)
KVX ACB 5.0.0 (GCC 12.2.1)
KVX ACB 5.2.0 (GCC 13.2.1)
LoongArch64 clang (trunk)
LoongArch64 clang 17.0.1
LoongArch64 clang 18.1.0
LoongArch64 clang 19.1.0
M68K gcc 13.1.0
M68K gcc 13.2.0
M68K gcc 13.3.0
M68K gcc 14.1.0
M68K gcc 14.2.0
M68k clang (trunk)
MRISC32 gcc (trunk)
MSP430 gcc 4.5.3
MSP430 gcc 5.3.0
MSP430 gcc 6.2.1
MinGW clang 14.0.3
MinGW clang 14.0.6
MinGW clang 15.0.7
MinGW clang 16.0.0
MinGW clang 16.0.2
MinGW gcc 11.3.0
MinGW gcc 12.1.0
MinGW gcc 12.2.0
MinGW gcc 13.1.0
RISC-V (32-bits) gcc (trunk)
RISC-V (32-bits) gcc 10.2.0
RISC-V (32-bits) gcc 10.3.0
RISC-V (32-bits) gcc 11.2.0
RISC-V (32-bits) gcc 11.3.0
RISC-V (32-bits) gcc 11.4.0
RISC-V (32-bits) gcc 12.1.0
RISC-V (32-bits) gcc 12.2.0
RISC-V (32-bits) gcc 12.3.0
RISC-V (32-bits) gcc 12.4.0
RISC-V (32-bits) gcc 13.1.0
RISC-V (32-bits) gcc 13.2.0
RISC-V (32-bits) gcc 13.3.0
RISC-V (32-bits) gcc 14.1.0
RISC-V (32-bits) gcc 14.2.0
RISC-V (32-bits) gcc 8.2.0
RISC-V (32-bits) gcc 8.5.0
RISC-V (32-bits) gcc 9.4.0
RISC-V (64-bits) gcc (trunk)
RISC-V (64-bits) gcc 10.2.0
RISC-V (64-bits) gcc 10.3.0
RISC-V (64-bits) gcc 11.2.0
RISC-V (64-bits) gcc 11.3.0
RISC-V (64-bits) gcc 11.4.0
RISC-V (64-bits) gcc 12.1.0
RISC-V (64-bits) gcc 12.2.0
RISC-V (64-bits) gcc 12.3.0
RISC-V (64-bits) gcc 12.4.0
RISC-V (64-bits) gcc 13.1.0
RISC-V (64-bits) gcc 13.2.0
RISC-V (64-bits) gcc 13.3.0
RISC-V (64-bits) gcc 14.1.0
RISC-V (64-bits) gcc 14.2.0
RISC-V (64-bits) gcc 8.2.0
RISC-V (64-bits) gcc 8.5.0
RISC-V (64-bits) gcc 9.4.0
RISC-V rv32gc clang (trunk)
RISC-V rv32gc clang 10.0.0
RISC-V rv32gc clang 10.0.1
RISC-V rv32gc clang 11.0.0
RISC-V rv32gc clang 11.0.1
RISC-V rv32gc clang 12.0.0
RISC-V rv32gc clang 12.0.1
RISC-V rv32gc clang 13.0.0
RISC-V rv32gc clang 13.0.1
RISC-V rv32gc clang 14.0.0
RISC-V rv32gc clang 15.0.0
RISC-V rv32gc clang 16.0.0
RISC-V rv32gc clang 17.0.1
RISC-V rv32gc clang 18.1.0
RISC-V rv32gc clang 19.1.0
RISC-V rv32gc clang 9.0.0
RISC-V rv32gc clang 9.0.1
RISC-V rv64gc clang (trunk)
RISC-V rv64gc clang 10.0.0
RISC-V rv64gc clang 10.0.1
RISC-V rv64gc clang 11.0.0
RISC-V rv64gc clang 11.0.1
RISC-V rv64gc clang 12.0.0
RISC-V rv64gc clang 12.0.1
RISC-V rv64gc clang 13.0.0
RISC-V rv64gc clang 13.0.1
RISC-V rv64gc clang 14.0.0
RISC-V rv64gc clang 15.0.0
RISC-V rv64gc clang 16.0.0
RISC-V rv64gc clang 17.0.1
RISC-V rv64gc clang 18.1.0
RISC-V rv64gc clang 19.1.0
RISC-V rv64gc clang 9.0.0
RISC-V rv64gc clang 9.0.1
Raspbian Buster
Raspbian Stretch
SPARC LEON gcc 12.2.0
SPARC LEON gcc 12.3.0
SPARC LEON gcc 12.4.0
SPARC LEON gcc 13.1.0
SPARC LEON gcc 13.2.0
SPARC LEON gcc 13.3.0
SPARC LEON gcc 14.1.0
SPARC LEON gcc 14.2.0
SPARC gcc 12.2.0
SPARC gcc 12.3.0
SPARC gcc 12.4.0
SPARC gcc 13.1.0
SPARC gcc 13.2.0
SPARC gcc 13.3.0
SPARC gcc 14.1.0
SPARC gcc 14.2.0
SPARC64 gcc 12.2.0
SPARC64 gcc 12.3.0
SPARC64 gcc 12.4.0
SPARC64 gcc 13.1.0
SPARC64 gcc 13.2.0
SPARC64 gcc 13.3.0
SPARC64 gcc 14.1.0
SPARC64 gcc 14.2.0
TI C6x gcc 12.2.0
TI C6x gcc 12.3.0
TI C6x gcc 12.4.0
TI C6x gcc 13.1.0
TI C6x gcc 13.2.0
TI C6x gcc 13.3.0
TI C6x gcc 14.1.0
TI C6x gcc 14.2.0
TI CL430 21.6.1
VAX gcc NetBSDELF 10.4.0
VAX gcc NetBSDELF 10.5.0 (Nov 15 03:50:22 2023)
WebAssembly clang (trunk)
Xtensa ESP32 gcc 11.2.0 (2022r1)
Xtensa ESP32 gcc 12.2.0 (20230208)
Xtensa ESP32 gcc 8.2.0 (2019r2)
Xtensa ESP32 gcc 8.2.0 (2020r1)
Xtensa ESP32 gcc 8.2.0 (2020r2)
Xtensa ESP32 gcc 8.4.0 (2020r3)
Xtensa ESP32 gcc 8.4.0 (2021r1)
Xtensa ESP32 gcc 8.4.0 (2021r2)
Xtensa ESP32-S2 gcc 11.2.0 (2022r1)
Xtensa ESP32-S2 gcc 12.2.0 (20230208)
Xtensa ESP32-S2 gcc 8.2.0 (2019r2)
Xtensa ESP32-S2 gcc 8.2.0 (2020r1)
Xtensa ESP32-S2 gcc 8.2.0 (2020r2)
Xtensa ESP32-S2 gcc 8.4.0 (2020r3)
Xtensa ESP32-S2 gcc 8.4.0 (2021r1)
Xtensa ESP32-S2 gcc 8.4.0 (2021r2)
Xtensa ESP32-S3 gcc 11.2.0 (2022r1)
Xtensa ESP32-S3 gcc 12.2.0 (20230208)
Xtensa ESP32-S3 gcc 8.4.0 (2020r3)
Xtensa ESP32-S3 gcc 8.4.0 (2021r1)
Xtensa ESP32-S3 gcc 8.4.0 (2021r2)
arm64 msvc v19.20 VS16.0
arm64 msvc v19.21 VS16.1
arm64 msvc v19.22 VS16.2
arm64 msvc v19.23 VS16.3
arm64 msvc v19.24 VS16.4
arm64 msvc v19.25 VS16.5
arm64 msvc v19.27 VS16.7
arm64 msvc v19.28 VS16.8
arm64 msvc v19.28 VS16.9
arm64 msvc v19.29 VS16.10
arm64 msvc v19.29 VS16.11
arm64 msvc v19.30 VS17.0
arm64 msvc v19.31 VS17.1
arm64 msvc v19.32 VS17.2
arm64 msvc v19.33 VS17.3
arm64 msvc v19.34 VS17.4
arm64 msvc v19.35 VS17.5
arm64 msvc v19.36 VS17.6
arm64 msvc v19.37 VS17.7
arm64 msvc v19.38 VS17.8
arm64 msvc v19.39 VS17.9
arm64 msvc v19.40 VS17.10
arm64 msvc v19.latest
armv7-a clang (trunk)
armv7-a clang 10.0.0
armv7-a clang 10.0.1
armv7-a clang 11.0.0
armv7-a clang 11.0.1
armv7-a clang 12.0.0
armv7-a clang 12.0.1
armv7-a clang 13.0.0
armv7-a clang 13.0.1
armv7-a clang 14.0.0
armv7-a clang 15.0.0
armv7-a clang 16.0.0
armv7-a clang 17.0.1
armv7-a clang 18.1.0
armv7-a clang 19.1.0
armv7-a clang 9.0.0
armv7-a clang 9.0.1
armv8-a clang (all architectural features, trunk)
armv8-a clang (trunk)
armv8-a clang 10.0.0
armv8-a clang 10.0.1
armv8-a clang 11.0.0
armv8-a clang 11.0.1
armv8-a clang 12.0.0
armv8-a clang 13.0.0
armv8-a clang 14.0.0
armv8-a clang 15.0.0
armv8-a clang 16.0.0
armv8-a clang 17.0.1
armv8-a clang 18.1.0
armv8-a clang 19.1.0
armv8-a clang 9.0.0
armv8-a clang 9.0.1
clang-cl 18.1.0
ellcc 0.1.33
ellcc 0.1.34
ellcc 2017-07-16
hexagon-clang 16.0.5
llvm-mos atari2600-3e
llvm-mos atari2600-4k
llvm-mos atari2600-common
llvm-mos atari5200-supercart
llvm-mos atari8-cart-megacart
llvm-mos atari8-cart-std
llvm-mos atari8-cart-xegs
llvm-mos atari8-common
llvm-mos atari8-dos
llvm-mos c128
llvm-mos c64
llvm-mos commodore
llvm-mos cpm65
llvm-mos cx16
llvm-mos dodo
llvm-mos eater
llvm-mos mega65
llvm-mos nes
llvm-mos nes-action53
llvm-mos nes-cnrom
llvm-mos nes-gtrom
llvm-mos nes-mmc1
llvm-mos nes-mmc3
llvm-mos nes-nrom
llvm-mos nes-unrom
llvm-mos nes-unrom-512
llvm-mos osi-c1p
llvm-mos pce
llvm-mos pce-cd
llvm-mos pce-common
llvm-mos pet
llvm-mos rp6502
llvm-mos rpc8e
llvm-mos supervision
llvm-mos vic20
loongarch64 gcc 12.2.0
loongarch64 gcc 12.3.0
loongarch64 gcc 12.4.0
loongarch64 gcc 13.1.0
loongarch64 gcc 13.2.0
loongarch64 gcc 13.3.0
loongarch64 gcc 14.1.0
loongarch64 gcc 14.2.0
mips clang 13.0.0
mips clang 14.0.0
mips clang 15.0.0
mips clang 16.0.0
mips clang 17.0.1
mips clang 18.1.0
mips clang 19.1.0
mips gcc 11.2.0
mips gcc 12.1.0
mips gcc 12.2.0
mips gcc 12.3.0
mips gcc 12.4.0
mips gcc 13.1.0
mips gcc 13.2.0
mips gcc 13.3.0
mips gcc 14.1.0
mips gcc 14.2.0
mips gcc 4.9.4
mips gcc 5.4
mips gcc 5.5.0
mips gcc 9.3.0 (codescape)
mips gcc 9.5.0
mips64 (el) gcc 12.1.0
mips64 (el) gcc 12.2.0
mips64 (el) gcc 12.3.0
mips64 (el) gcc 12.4.0
mips64 (el) gcc 13.1.0
mips64 (el) gcc 13.2.0
mips64 (el) gcc 13.3.0
mips64 (el) gcc 14.1.0
mips64 (el) gcc 14.2.0
mips64 (el) gcc 4.9.4
mips64 (el) gcc 5.4.0
mips64 (el) gcc 5.5.0
mips64 (el) gcc 9.5.0
mips64 clang 13.0.0
mips64 clang 14.0.0
mips64 clang 15.0.0
mips64 clang 16.0.0
mips64 clang 17.0.1
mips64 clang 18.1.0
mips64 clang 19.1.0
mips64 gcc 11.2.0
mips64 gcc 12.1.0
mips64 gcc 12.2.0
mips64 gcc 12.3.0
mips64 gcc 12.4.0
mips64 gcc 13.1.0
mips64 gcc 13.2.0
mips64 gcc 13.3.0
mips64 gcc 14.1.0
mips64 gcc 14.2.0
mips64 gcc 4.9.4
mips64 gcc 5.4.0
mips64 gcc 5.5.0
mips64 gcc 9.5.0
mips64el clang 13.0.0
mips64el clang 14.0.0
mips64el clang 15.0.0
mips64el clang 16.0.0
mips64el clang 17.0.1
mips64el clang 18.1.0
mips64el clang 19.1.0
mipsel clang 13.0.0
mipsel clang 14.0.0
mipsel clang 15.0.0
mipsel clang 16.0.0
mipsel clang 17.0.1
mipsel clang 18.1.0
mipsel clang 19.1.0
mipsel gcc 12.1.0
mipsel gcc 12.2.0
mipsel gcc 12.3.0
mipsel gcc 12.4.0
mipsel gcc 13.1.0
mipsel gcc 13.2.0
mipsel gcc 13.3.0
mipsel gcc 14.1.0
mipsel gcc 14.2.0
mipsel gcc 4.9.4
mipsel gcc 5.4.0
mipsel gcc 5.5.0
mipsel gcc 9.5.0
nanoMIPS gcc 6.3.0 (mtk)
power gcc 11.2.0
power gcc 12.1.0
power gcc 12.2.0
power gcc 12.3.0
power gcc 12.4.0
power gcc 13.1.0
power gcc 13.2.0
power gcc 13.3.0
power gcc 14.1.0
power gcc 14.2.0
power gcc 4.8.5
power64 AT12.0 (gcc8)
power64 AT13.0 (gcc9)
power64 gcc 11.2.0
power64 gcc 12.1.0
power64 gcc 12.2.0
power64 gcc 12.3.0
power64 gcc 12.4.0
power64 gcc 13.1.0
power64 gcc 13.2.0
power64 gcc 13.3.0
power64 gcc 14.1.0
power64 gcc 14.2.0
power64 gcc trunk
power64le AT12.0 (gcc8)
power64le AT13.0 (gcc9)
power64le clang (trunk)
power64le gcc 11.2.0
power64le gcc 12.1.0
power64le gcc 12.2.0
power64le gcc 12.3.0
power64le gcc 12.4.0
power64le gcc 13.1.0
power64le gcc 13.2.0
power64le gcc 13.3.0
power64le gcc 14.1.0
power64le gcc 14.2.0
power64le gcc 6.3.0
power64le gcc trunk
powerpc64 clang (trunk)
s390x gcc 11.2.0
s390x gcc 12.1.0
s390x gcc 12.2.0
s390x gcc 12.3.0
s390x gcc 12.4.0
s390x gcc 13.1.0
s390x gcc 13.2.0
s390x gcc 13.3.0
s390x gcc 14.1.0
s390x gcc 14.2.0
sh gcc 12.2.0
sh gcc 12.3.0
sh gcc 12.4.0
sh gcc 13.1.0
sh gcc 13.2.0
sh gcc 13.3.0
sh gcc 14.1.0
sh gcc 14.2.0
sh gcc 4.9.4
sh gcc 9.5.0
vast (trunk)
x64 msvc v19.0 (WINE)
x64 msvc v19.10 (WINE)
x64 msvc v19.14 (WINE)
x64 msvc v19.20 VS16.0
x64 msvc v19.21 VS16.1
x64 msvc v19.22 VS16.2
x64 msvc v19.23 VS16.3
x64 msvc v19.24 VS16.4
x64 msvc v19.25 VS16.5
x64 msvc v19.27 VS16.7
x64 msvc v19.28 VS16.8
x64 msvc v19.28 VS16.9
x64 msvc v19.29 VS16.10
x64 msvc v19.29 VS16.11
x64 msvc v19.30 VS17.0
x64 msvc v19.31 VS17.1
x64 msvc v19.32 VS17.2
x64 msvc v19.33 VS17.3
x64 msvc v19.34 VS17.4
x64 msvc v19.35 VS17.5
x64 msvc v19.36 VS17.6
x64 msvc v19.37 VS17.7
x64 msvc v19.38 VS17.8
x64 msvc v19.39 VS17.9
x64 msvc v19.40 VS17.10
x64 msvc v19.latest
x86 djgpp 4.9.4
x86 djgpp 5.5.0
x86 djgpp 6.4.0
x86 djgpp 7.2.0
x86 msvc v19.0 (WINE)
x86 msvc v19.10 (WINE)
x86 msvc v19.14 (WINE)
x86 msvc v19.20 VS16.0
x86 msvc v19.21 VS16.1
x86 msvc v19.22 VS16.2
x86 msvc v19.23 VS16.3
x86 msvc v19.24 VS16.4
x86 msvc v19.25 VS16.5
x86 msvc v19.27 VS16.7
x86 msvc v19.28 VS16.8
x86 msvc v19.28 VS16.9
x86 msvc v19.29 VS16.10
x86 msvc v19.29 VS16.11
x86 msvc v19.30 VS17.0
x86 msvc v19.31 VS17.1
x86 msvc v19.32 VS17.2
x86 msvc v19.33 VS17.3
x86 msvc v19.34 VS17.4
x86 msvc v19.35 VS17.5
x86 msvc v19.36 VS17.6
x86 msvc v19.37 VS17.7
x86 msvc v19.38 VS17.8
x86 msvc v19.39 VS17.9
x86 msvc v19.40 VS17.10
x86 msvc v19.latest
x86 nvc++ 22.11
x86 nvc++ 22.7
x86 nvc++ 22.9
x86 nvc++ 23.1
x86 nvc++ 23.11
x86 nvc++ 23.3
x86 nvc++ 23.5
x86 nvc++ 23.7
x86 nvc++ 23.9
x86 nvc++ 24.1
x86 nvc++ 24.11
x86 nvc++ 24.3
x86 nvc++ 24.5
x86 nvc++ 24.7
x86 nvc++ 24.9
x86-64 Zapcc 190308
x86-64 clang (Chris Bazley N3089)
x86-64 clang (EricWF contracts)
x86-64 clang (amd-staging)
x86-64 clang (assertions trunk)
x86-64 clang (clangir)
x86-64 clang (dascandy contracts)
x86-64 clang (experimental -Wlifetime)
x86-64 clang (experimental P1061)
x86-64 clang (experimental P1144)
x86-64 clang (experimental P1221)
x86-64 clang (experimental P2996)
x86-64 clang (experimental P2998)
x86-64 clang (experimental P3068)
x86-64 clang (experimental P3309)
x86-64 clang (experimental P3367)
x86-64 clang (experimental P3372)
x86-64 clang (experimental metaprogramming - P2632)
x86-64 clang (old concepts branch)
x86-64 clang (p1974)
x86-64 clang (pattern matching - P2688)
x86-64 clang (reflection)
x86-64 clang (resugar)
x86-64 clang (string interpolation - P3412)
x86-64 clang (thephd.dev)
x86-64 clang (trunk)
x86-64 clang (variadic friends - P2893)
x86-64 clang (widberg)
x86-64 clang 10.0.0
x86-64 clang 10.0.0 (assertions)
x86-64 clang 10.0.1
x86-64 clang 11.0.0
x86-64 clang 11.0.0 (assertions)
x86-64 clang 11.0.1
x86-64 clang 12.0.0
x86-64 clang 12.0.0 (assertions)
x86-64 clang 12.0.1
x86-64 clang 13.0.0
x86-64 clang 13.0.0 (assertions)
x86-64 clang 13.0.1
x86-64 clang 14.0.0
x86-64 clang 14.0.0 (assertions)
x86-64 clang 15.0.0
x86-64 clang 15.0.0 (assertions)
x86-64 clang 16.0.0
x86-64 clang 16.0.0 (assertions)
x86-64 clang 17.0.1
x86-64 clang 17.0.1 (assertions)
x86-64 clang 18.1.0
x86-64 clang 18.1.0 (assertions)
x86-64 clang 19.1.0
x86-64 clang 19.1.0 (assertions)
x86-64 clang 2.6.0 (assertions)
x86-64 clang 2.7.0 (assertions)
x86-64 clang 2.8.0 (assertions)
x86-64 clang 2.9.0 (assertions)
x86-64 clang 3.0.0
x86-64 clang 3.0.0 (assertions)
x86-64 clang 3.1
x86-64 clang 3.1 (assertions)
x86-64 clang 3.2
x86-64 clang 3.2 (assertions)
x86-64 clang 3.3
x86-64 clang 3.3 (assertions)
x86-64 clang 3.4 (assertions)
x86-64 clang 3.4.1
x86-64 clang 3.5
x86-64 clang 3.5 (assertions)
x86-64 clang 3.5.1
x86-64 clang 3.5.2
x86-64 clang 3.6
x86-64 clang 3.6 (assertions)
x86-64 clang 3.7
x86-64 clang 3.7 (assertions)
x86-64 clang 3.7.1
x86-64 clang 3.8
x86-64 clang 3.8 (assertions)
x86-64 clang 3.8.1
x86-64 clang 3.9.0
x86-64 clang 3.9.0 (assertions)
x86-64 clang 3.9.1
x86-64 clang 4.0.0
x86-64 clang 4.0.0 (assertions)
x86-64 clang 4.0.1
x86-64 clang 5.0.0
x86-64 clang 5.0.0 (assertions)
x86-64 clang 5.0.1
x86-64 clang 5.0.2
x86-64 clang 6.0.0
x86-64 clang 6.0.0 (assertions)
x86-64 clang 6.0.1
x86-64 clang 7.0.0
x86-64 clang 7.0.0 (assertions)
x86-64 clang 7.0.1
x86-64 clang 7.1.0
x86-64 clang 8.0.0
x86-64 clang 8.0.0 (assertions)
x86-64 clang 8.0.1
x86-64 clang 9.0.0
x86-64 clang 9.0.0 (assertions)
x86-64 clang 9.0.1
x86-64 clang rocm-4.5.2
x86-64 clang rocm-5.0.2
x86-64 clang rocm-5.1.3
x86-64 clang rocm-5.2.3
x86-64 clang rocm-5.3.3
x86-64 clang rocm-5.7.0
x86-64 clang rocm-6.0.2
x86-64 clang rocm-6.1.2
x86-64 gcc (contract labels)
x86-64 gcc (contracts natural syntax)
x86-64 gcc (contracts)
x86-64 gcc (coroutines)
x86-64 gcc (modules)
x86-64 gcc (trunk)
x86-64 gcc 10.1
x86-64 gcc 10.2
x86-64 gcc 10.3
x86-64 gcc 10.3 (assertions)
x86-64 gcc 10.4
x86-64 gcc 10.4 (assertions)
x86-64 gcc 10.5
x86-64 gcc 10.5 (assertions)
x86-64 gcc 11.1
x86-64 gcc 11.1 (assertions)
x86-64 gcc 11.2
x86-64 gcc 11.2 (assertions)
x86-64 gcc 11.3
x86-64 gcc 11.3 (assertions)
x86-64 gcc 11.4
x86-64 gcc 11.4 (assertions)
x86-64 gcc 12.1
x86-64 gcc 12.1 (assertions)
x86-64 gcc 12.2
x86-64 gcc 12.2 (assertions)
x86-64 gcc 12.3
x86-64 gcc 12.3 (assertions)
x86-64 gcc 12.4
x86-64 gcc 12.4 (assertions)
x86-64 gcc 13.1
x86-64 gcc 13.1 (assertions)
x86-64 gcc 13.2
x86-64 gcc 13.2 (assertions)
x86-64 gcc 13.3
x86-64 gcc 13.3 (assertions)
x86-64 gcc 14.1
x86-64 gcc 14.1 (assertions)
x86-64 gcc 14.2
x86-64 gcc 14.2 (assertions)
x86-64 gcc 3.4.6
x86-64 gcc 4.0.4
x86-64 gcc 4.1.2
x86-64 gcc 4.4.7
x86-64 gcc 4.5.3
x86-64 gcc 4.6.4
x86-64 gcc 4.7.1
x86-64 gcc 4.7.2
x86-64 gcc 4.7.3
x86-64 gcc 4.7.4
x86-64 gcc 4.8.1
x86-64 gcc 4.8.2
x86-64 gcc 4.8.3
x86-64 gcc 4.8.4
x86-64 gcc 4.8.5
x86-64 gcc 4.9.0
x86-64 gcc 4.9.1
x86-64 gcc 4.9.2
x86-64 gcc 4.9.3
x86-64 gcc 4.9.4
x86-64 gcc 5.1
x86-64 gcc 5.2
x86-64 gcc 5.3
x86-64 gcc 5.4
x86-64 gcc 5.5
x86-64 gcc 6.1
x86-64 gcc 6.2
x86-64 gcc 6.3
x86-64 gcc 6.4
x86-64 gcc 6.5
x86-64 gcc 7.1
x86-64 gcc 7.2
x86-64 gcc 7.3
x86-64 gcc 7.4
x86-64 gcc 7.5
x86-64 gcc 8.1
x86-64 gcc 8.2
x86-64 gcc 8.3
x86-64 gcc 8.4
x86-64 gcc 8.5
x86-64 gcc 9.1
x86-64 gcc 9.2
x86-64 gcc 9.3
x86-64 gcc 9.4
x86-64 gcc 9.5
x86-64 icc 13.0.1
x86-64 icc 16.0.3
x86-64 icc 17.0.0
x86-64 icc 18.0.0
x86-64 icc 19.0.0
x86-64 icc 19.0.1
x86-64 icc 2021.1.2
x86-64 icc 2021.10.0
x86-64 icc 2021.2.0
x86-64 icc 2021.3.0
x86-64 icc 2021.4.0
x86-64 icc 2021.5.0
x86-64 icc 2021.6.0
x86-64 icc 2021.7.0
x86-64 icc 2021.7.1
x86-64 icc 2021.8.0
x86-64 icc 2021.9.0
x86-64 icx 2021.1.2
x86-64 icx 2021.2.0
x86-64 icx 2021.3.0
x86-64 icx 2021.4.0
x86-64 icx 2022.0.0
x86-64 icx 2022.1.0
x86-64 icx 2022.2.0
x86-64 icx 2022.2.1
x86-64 icx 2023.0.0
x86-64 icx 2023.1.0
x86-64 icx 2023.2.1
x86-64 icx 2024.0.0
x86-64 icx 2024.1.0
x86-64 icx 2024.2.0
x86-64 icx 2025.0.0
x86-64 icx 2025.0.0
zig c++ 0.10.0
zig c++ 0.11.0
zig c++ 0.12.0
zig c++ 0.12.1
zig c++ 0.13.0
zig c++ 0.6.0
zig c++ 0.7.0
zig c++ 0.7.1
zig c++ 0.8.0
zig c++ 0.9.0
zig c++ trunk
Options
Source code
#include <iostream> #include <string> #include <algorithm> #include <functional> #include <chrono> #include <fstream> #include <string_view> #include <sstream> #include <numeric> #include <string.h> #include <ranges> #ifdef _MSC_VER #pragma optimize("", off) template <class T> void DoNotOptimizeAway(T&& datum) { datum = datum; } #pragma optimize("", on) #elif defined(__clang__) template <class T> __attribute__((__optnone__)) void DoNotOptimizeAway(T&& /* datum */) {} #else template <class T> void DoNotOptimizeAway(T&& datum) { asm volatile("" : "+r" (datum)); } #endif template <typename TFunc> void RunAndMeasure(const char* title, TFunc func) { const auto start = std::chrono::steady_clock::now(); auto ret = func(); const auto end = std::chrono::steady_clock::now(); DoNotOptimizeAway(ret); std::cout << title << ": " << std::chrono::duration <double, std::milli>(end - start).count() << " ms\n"; } using namespace std::literals; const std::string_view LoremIpsumStrv{ R"(Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ullamcorper malesuada proin libero nunc consequat interdum varius sit amet. Quis lectus nulla at volutpat diam. Tellus rutrum tellus pellentesque eu. Varius duis at consectetur lorem donec massa sapien faucibus. Tristique nulla aliquet enim tortor at auctor urna nunc id. Risus in hendrerit gravida rutrum quisque non tellus orci. Sem nulla pharetra diam sit amet nisl. Vitae aliquet nec ullamcorper sit. Aliquam ut porttitor leo a. Ipsum suspendisse ultrices gravida dictum fusce ut. Auctor neque vitae tempus quam pellentesque nec. Ultrices in iaculis nunc sed augue lacus. Sem fringilla ut morbi tincidunt augue interdum velit. Maecenas accumsan lacus vel facilisis volutpat est velit egestas. Eu consequat ac felis donec et odio pellentesque. Leo urna molestie at elementum. Enim facilisis gravida neque convallis a. Suspendisse faucibus interdum posuere lorem. Proin sed libero enim sed faucibus. Feugiat nibh sed pulvinar proin gravida hendrerit lectus. Ultrices vitae auctor eu augue ut. Accumsan sit amet nulla facilisi morbi tempus iaculis urna. At lectus urna duis convallis convallis tellus id interdum velit. Vel quam elementum pulvinar etiam non. Ac placerat vestibulum lectus mauris. Amet mauris commodo quis imperdiet massa tincidunt nunc pulvinar. Molestie at elementum eu facilisis. Nunc pulvinar sapien et ligula ullamcorper malesuada proin. Lacus luctus accumsan tortor posuere ac ut consequat semper viverra. Quis imperdiet massa tincidunt nunc pulvinar sapien. Amet tellus cras adipiscing enim eu turpis. Et ligula ullamcorper malesuada proin libero nunc consequat. In fermentum posuere urna nec tincidunt praesent semper feugiat. Aenean sed adipiscing diam donec adipiscing tristique risus nec feugiat. Pellentesque elit eget gravida cum sociis natoque penatibus et. Lobortis scelerisque fermentum dui faucibus in ornare quam viverra. Est ante in nibh mauris cursus mattis. Mattis rhoncus urna neque viverra justo. Ridiculus mus mauris vitae ultricies leo integer malesuada nunc. Auctor eu augue ut lectus arcu bibendum at varius. Diam volutpat commodo sed egestas egestas fringilla phasellus faucibus scelerisque. Orci eu lobortis elementum nibh. Ullamcorper sit amet risus nullam eget felis eget nunc lobortis. Habitasse platea dictumst vestibulum rhoncus est pellentesque. Nam at lectus urna duis. Ultrices in iaculis nunc sed. Nullam eget felis eget nunc lobortis mattis aliquam faucibus. Vel orci porta non pulvinar. At in tellus integer feugiat scelerisque varius. Sed elementum tempus egestas sed sed risus pretium quam. Id cursus metus aliquam eleifend mi. Et leo duis ut diam quam nulla. Nibh sit amet commodo nulla. Lectus quam id leo in vitae turpis massa sed elementum. Odio aenean sed adipiscing diam donec. Pellentesque elit ullamcorper dignissim cras. Ac turpis egestas maecenas pharetra convallis posuere morbi leo. Pharetra magna ac placerat vestibulum lectus mauris ultrices eros in. Auctor urna nunc id cursus metus. Ipsum a arcu cursus vitae congue mauris rhoncus. Lacus sed turpis tincidunt id aliquet risus feugiat in ante. Ut porttitor leo a diam sollicitudin tempor id. Nec feugiat nisl pretium fusce id velit. Et netus et malesuada fames ac turpis egestas. Eu turpis egestas pretium aenean pharetra magna ac. Ut pharetra sit amet aliquam id diam maecenas ultricies mi. Lacus vestibulum sed arcu non. Sem nulla pharetra diam sit amet nisl. In ante metus dictum at tempor commodo ullamcorper a lacus. Volutpat ac tincidunt vitae semper quis lectus. Volutpat est velit egestas dui id ornare arcu odio ut. Fermentum posuere urna nec tincidunt praesent semper feugiat nibh sed. Mattis vulputate enim nulla aliquet porttitor lacus luctus. Felis donec et odio pellentesque diam volutpat commodo sed. Facilisi morbi tempus iaculis urna id volutpat lacus laoreet. Ipsum consequat nisl vel pretium lectus. Commodo viverra maecenas accumsan lacus vel facilisis volutpat est. At quis risus sed vulputate odio ut enim. At quis risus sed vulputate odio. Consequat id porta nibh venenatis cras sed felis eget. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Quis auctor elit sed vulputate mi sit. Elit ut aliquam purus sit amet. Sit amet consectetur adipiscing elit duis tristique sollicitudin nibh. Tellus mauris a diam maecenas sed enim ut sem viverra. Scelerisque felis imperdiet proin fermentum leo vel. Amet purus gravida quis blandit turpis. Sollicitudin ac orci phasellus egestas tellus rutrum tellus pellentesque. Scelerisque fermentum dui faucibus in ornare quam viverra. Quam vulputate dignissim suspendisse in est ante in nibh mauris. Et egestas quis ipsum suspendisse. Pellentesque habitant morbi tristique senectus et netus et malesuada fames. Velit egestas dui id ornare. Est pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat. Posuere urna nec tincidunt praesent. Quis imperdiet massa tincidunt nunc pulvinar. Amet mattis vulputate enim nulla aliquet porttitor lacus luctus accumsan. Enim tortor at auctor urna nunc id cursus metus. Suscipit adipiscing bibendum est ultricies integer quis auctor elit. Et molestie ac feugiat sed lectus. Quam quisque id diam vel. Orci eu lobortis elementum nibh tellus molestie nunc non blandit. Suspendisse in est ante in nibh mauris cursus. Aliquam purus sit amet luctus venenatis lectus magna fringilla. Dignissim suspendisse in est ante in nibh mauris cursus mattis. Diam quam nulla porttitor massa id neque aliquam. Duis at consectetur lorem donec massa sapien. Eget duis at tellus at urna. Placerat vestibulum lectus mauris ultrices eros. Nisi est sit amet facilisis. Risus sed vulputate odio ut enim blandit. Morbi tincidunt augue interdum velit euismod. Sit amet tellus cras adipiscing enim eu turpis egestas pretium. Facilisis leo vel fringilla est ullamcorper eget nulla. Dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras. Sagittis vitae et leo duis ut. Amet cursus sit amet dictum sit amet justo. Tortor condimentum lacinia quis vel eros. Purus ut faucibus pulvinar elementum integer enim neque. Montes nascetur ridiculus mus mauris vitae ultricies leo. Pretium aenean pharetra magna ac placerat vestibulum lectus. Molestie a iaculis at erat pellentesque adipiscing commodo. Aliquam purus sit amet luctus venenatis lectus magna fringilla. Dignissim sodales ut eu sem. Aliquet risus feugiat in ante metus dictum at. Est sit amet facilisis magna etiam. Ornare aenean euismod elementum nisi. Aliquam eleifend mi in nulla posuere sollicitudin. Id interdum velit laoreet id donec ultrices tincidunt arcu non. Maecenas sed enim ut sem viverra aliquet. Est pellentesque elit ullamcorper dignissim. Morbi tristique senectus et netus et malesuada fames. Aliquam eleifend mi in nulla. Felis eget velit aliquet sagittis id consectetur purus ut faucibus. Sit amet cursus sit amet dictum sit amet justo donec. Duis ut diam quam nulla porttitor massa id neque aliquam. Sollicitudin ac orci phasellus egestas tellus rutrum. Mattis enim ut tellus elementum sagittis vitae et. Tristique nulla aliquet enim tortor at auctor. Natoque penatibus et magnis dis parturient. Ullamcorper a lacus vestibulum sed arcu non odio. Ut morbi tincidunt augue interdum velit euismod in pellentesque. Lacus viverra vitae congue eu consequat ac felis. Ultrices dui sapien eget mi proin sed libero enim sed. Convallis a cras semper auctor neque. Donec adipiscing tristique risus nec feugiat in fermentum posuere urna. Id eu nisl nunc mi ipsum faucibus vitae aliquet. Felis eget nunc lobortis mattis aliquam faucibus purus in massa. Dignissim enim sit amet venenatis. Pharetra magna ac placerat vestibulum. Eu ultrices vitae auctor eu augue ut lectus arcu. Bibendum ut tristique et egestas. Odio morbi quis commodo odio. Est sit amet facilisis magna etiam tempor. Est sit amet facilisis magna etiam tempor orci eu lobortis. Sagittis purus sit amet volutpat consequat mauris nunc congue nisi. Elementum tempus egestas sed sed risus pretium. Et netus et malesuada fames ac turpis. Tellus elementum sagittis vitae et leo duis. In hac habitasse platea dictumst quisque. Felis eget velit aliquet sagittis id consectetur purus. Risus nullam eget felis eget. Maecenas accumsan lacus vel facilisis volutpat. Odio tempor orci dapibus ultrices in iaculis. In est ante in nibh mauris. Dapibus ultrices in iaculis nunc sed. Sed odio morbi quis commodo odio. Feugiat vivamus at augue eget. Sapien faucibus et molestie ac feugiat sed lectus vestibulum mattis. Purus non enim praesent elementum facilisis leo. Aliquet lectus proin nibh nisl condimentum id venenatis. Massa tempor nec feugiat nisl. Ut sem nulla pharetra diam sit amet nisl suscipit. Ut eu sem integer vitae justo eget magna fermentum. Condimentum id venenatis a condimentum vitae sapien pellentesque habitant morbi. Scelerisque fermentum dui faucibus in ornare quam viverra. Pretium aenean pharetra magna ac placerat vestibulum lectus mauris. Eget mi proin sed libero enim sed faucibus turpis in. Tincidunt ornare massa eget egestas purus viverra accumsan in. At augue eget arcu dictum varius duis at consectetur lorem. Vulputate mi sit amet mauris commodo quis imperdiet massa. Sit amet massa vitae tortor condimentum lacinia quis. Neque sodales ut etiam sit amet nisl purus in mollis. Sagittis id consectetur purus ut faucibus pulvinar. Morbi tincidunt ornare massa eget egestas. Urna duis convallis convallis tellus id. Amet consectetur adipiscing elit pellentesque habitant morbi. Dictum fusce ut placerat orci nulla pellentesque dignissim enim. Sem et tortor consequat id porta nibh. Donec enim diam vulputate ut pharetra sit. Egestas fringilla phasellus faucibus scelerisque. Rhoncus aenean vel elit scelerisque mauris pellentesque. Est sit amet facilisis magna etiam. Mauris rhoncus aenean vel elit. Nulla facilisi etiam dignissim diam quis enim lobortis. Amet luctus venenatis lectus magna fringilla urna. Id leo in vitae turpis. Mi eget mauris pharetra et ultrices neque. Nec sagittis aliquam malesuada bibendum arcu vitae elementum. Iaculis nunc sed augue lacus viverra. Viverra nibh cras pulvinar mattis nunc sed blandit libero. Dignissim suspendisse in est ante in nibh mauris cursus mattis. Enim tortor at auctor urna nunc id cursus. Auctor neque vitae tempus quam pellentesque nec nam. Pharetra pharetra massa massa ultricies mi quis. Tristique nulla aliquet enim tortor at auctor. Pulvinar elementum integer enim neque. Velit aliquet sagittis id consectetur purus. Feugiat sed lectus vestibulum mattis. Odio eu feugiat pretium nibh ipsum consequat. Dignissim enim sit amet venenatis urna cursus. Sed enim ut sem viverra aliquet eget sit. Mattis rhoncus urna neque viverra justo nec ultrices. Amet consectetur adipiscing elit duis tristique sollicitudin. Nam at lectus urna duis convallis. Ut placerat orci nulla pellentesque dignissim enim sit amet. Quis eleifend quam adipiscing vitae proin. Enim eu turpis egestas pretium. Sollicitudin nibh sit amet commodo nulla facilisi. Sed risus pretium quam vulputate. Eget mi proin sed libero enim sed faucibus. Turpis egestas pretium aenean pharetra. Quisque non tellus orci ac auctor. Quam nulla porttitor massa id neque aliquam. Vel eros donec ac odio tempor orci dapibus. Donec et odio pellentesque diam volutpat commodo sed egestas. Vel pretium lectus quam id leo in vitae turpis. Accumsan tortor posuere ac ut consequat semper viverra. Eros donec ac odio tempor orci dapibus. Ultrices mi tempus imperdiet nulla malesuada pellentesque elit eget gravida. )" }; std::vector<std::string> GetNeedleStrings(int argc, const char** argv, std::string &testString, size_t needleCount) { const auto testStringLen = testString.length(); std::vector<std::string> out; out.resize(needleCount); long posStart = 0; size_t patternLen = testStringLen; if (argc > 3) { const size_t tempLen = atoi(argv[3]); if (tempLen == 0) // some word? { std::cout << "needle is a string...\n"; out[0] = argv[3]; } else { patternLen = tempLen > testStringLen ? testStringLen : tempLen; const int pos = argc > 4 ? atoi(argv[4]) : 0; if (pos == 0) { std::cout << "needle from the start...\n"; posStart = 0; } else if (pos == 1) { std::cout << "needle from the center...\n"; posStart = static_cast<long>(testStringLen / 2 - patternLen / 2 - needleCount/2); } else { std::cout << "needle from the end\n"; posStart = static_cast<long>(testStringLen - patternLen - needleCount); } } } else { // just take the 1/4 of the input string from the end... std::cout << "needle in 1/4 of the input string from the end...\n"; posStart = static_cast<long>(testStringLen - testStringLen / 4 - needleCount / 2); } posStart = std::max(0L, posStart); for (size_t i = 0; i < needleCount; ++i) { out[i] = testString.substr(posStart + i, patternLen); } return out; } // based on a twitter suggestion - Gregory Pakosz // https://gist.github.com/gpakosz/22ff3793017d6823c65727c8ba3480b7 static char* strchr_find(const char* haystackBegin, const char* haystackEnd, const char* needleBegin, const char* needleEnd) { if (haystackEnd == NULL) haystackEnd = haystackBegin + strlen(haystackBegin); if (needleEnd == NULL) needleEnd = needleBegin + strlen(needleBegin); size_t haystackLength = haystackEnd - haystackBegin; size_t needleLength = needleEnd - needleBegin; if (haystackLength < needleLength) return NULL; if (needleBegin == needleEnd) return (char*)haystackBegin; if (needleLength == 1) return (char*)memchr(haystackBegin, needleBegin[0], haystackLength); while ((haystackBegin = (const char*)memchr(haystackBegin, needleBegin[0], haystackLength)) != NULL) { haystackLength = (size_t)(haystackEnd - haystackBegin); if (haystackLength == 0 || haystackLength < needleLength) return NULL; if (haystackBegin[needleLength - 1] == needleBegin[needleLength - 1]) { if (needleLength == 2 || memcmp(haystackBegin + 1, needleBegin + 1, needleLength - 2) == 0) return (char*)haystackBegin; } ++haystackBegin; --haystackLength; } return nullptr; } int main(int argc, const char** argv) { std::string testString{ LoremIpsumStrv }; if (argc > 1 && "nofile"s != argv[1]) { std::ifstream inFile(argv[1]); std::stringstream strStream; strStream << inFile.rdbuf(); testString = strStream.str(); } std::cout << "string length: " << testString.length() << '\n'; const size_t ITERS = argc > 2 ? atoi(argv[2]) : 5000; std::cout << "test iterations: " << ITERS << '\n'; const size_t PATTERNS = ITERS / 10; const auto needles = GetNeedleStrings(argc, argv, testString, PATTERNS); std::cout << "patterns count: " << needles.size() << '\n'; std::cout << "patterns len: " << needles[0].length() << '\n'; std::cout << "5 first patterns, 30 letters max: \n"; for (auto pat : needles | std::views::take(5)) { if (pat.length() > 30) pat[30] = '\0'; std::cout << pat.c_str() << '\n'; } RunAndMeasure("string::find", [&]() { for (size_t i = 0; i < ITERS; ++i) { std::size_t found = testString.find(needles[i % PATTERNS]); if (found == std::string::npos) std::cout << "The string " << needles[i % PATTERNS] << " not found\n"; } return 0; }); RunAndMeasure("strchr_find", [&]() { for (size_t i = 0; i < ITERS; ++i) { const char* strEnd = &testString[0] + testString.length(); const char* needleEnd = &needles[i % PATTERNS][0] + needles[i % PATTERNS].length(); auto found = strchr_find(&testString[0], strEnd, &needles[i % PATTERNS][0], needleEnd); if (found == nullptr) std::cout << "The string " << needles[i % PATTERNS] << " not found\n"; } return 0; }); RunAndMeasure("std::ranges::search", [&]() { for (size_t i = 0; i < ITERS; ++i) { auto res = std::ranges::search(testString, needles[i % PATTERNS]); if (res.empty()) std::cout << "The string " << needles[i % PATTERNS] << " not found\n"; } return 0; }); RunAndMeasure("default searcher", [&]() { for (size_t i = 0; i < ITERS; ++i) { auto it = std::search(testString.begin(), testString.end(), std::default_searcher( needles[i % PATTERNS].begin(), needles[i % PATTERNS].end())); if (it == testString.end()) std::cout << "The string " << needles[i % PATTERNS] << " not found\n"; } return 0; }); RunAndMeasure("boyer_moore_searcher init only", [&]() { for (size_t i = 0; i < ITERS; ++i) { std::boyer_moore_searcher b(needles[i % PATTERNS].begin(), needles[i % PATTERNS].end()); //DoNotOptimizeAway(&b); } return 0; }); RunAndMeasure("boyer_moore_searcher", [&]() { for (size_t i = 0; i < ITERS; ++i) { auto it = std::search(testString.begin(), testString.end(), std::boyer_moore_searcher( needles[i % PATTERNS].begin(), needles[i % PATTERNS].end())); if (it == testString.end()) std::cout << "The string " << needles[i % PATTERNS] << " not found\n"; } return 0; }); RunAndMeasure("boyer_moore_horspool_searcher init only", [&]() { for (size_t i = 0; i < ITERS; ++i) { std::boyer_moore_horspool_searcher b(needles[i % PATTERNS].begin(), needles[i % PATTERNS].end()); //DoNotOptimizeAway(&b); } return 0; }); RunAndMeasure("boyer_moore_horspool_searcher", [&]() { for (size_t i = 0; i < ITERS; ++i) { auto it = std::search(testString.begin(), testString.end(), std::boyer_moore_horspool_searcher( needles[i % PATTERNS].begin(), needles[i % PATTERNS].end())); if (it == testString.end()) std::cout << "The string " << needles[i % PATTERNS] << " not found\n"; } return 0; }); }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
About the author
Statistics
Changelog
Version tree