this post was submitted on 02 Jul 2023
6 points (100.0% liked)

C++

1755 readers
1 users here now

The center for all discussion and news regarding C++.

Rules

founded 1 year ago
MODERATORS
 

My implementation of the move-and-pop idiom for single, ranged and erase_if erasures respectively: https://plflib.org/reorderase.htm

Performance: Single erasures: 1010566% faster than .erase(position) on average (ie. 10157 x original speed), with a minimum of 10% faster for a vector of 10 ints, and a maximum of 25974010% faster for 870000 490-byte structs.

Ranged erasures: 12570% faster than .erase(first, last) on average, with a minimum of 20% faster for a vector of 10 ints, and a maximum of 77679% for 920000 490-byte structs.

std::erase_if/std::erase-style erasures: Not quite as incredible, this typically only outperforms the std:: equivalents on types larger than 25 bytes. 38% faster on average, with a minimum of 10% slower for 50 doubles, and a maximum of 180% for 920000 490-byte structs.

Full benchmarks + more detailed stats breakdowns are on the page.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here