Skip to content

Instantly share code, notes, and snippets.

View riteme's full-sized avatar
✔️
sudo pacman -Syyuu

Xue Zhenliang riteme

✔️
sudo pacman -Syyuu
View GitHub Profile
@riteme
riteme / main.md
Last active January 5, 2023 05:38
Memcpy is faster than memset on Intel i7 12700 with glibc 2.36

The code memset_test.cpp:

#include <cstdio>
#include <cstring>

void *my_memset(void *s, int c, size_t n) {
    constexpr size_t threshold = 2 * 2048 * 2048;  // 2 MiB
    if (n > threshold) {
        // Only memset the first 2 MiB part of s