This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////// | |
// compile with: | |
// $ gcc -O3 -march=native -fno-builtin -o /tmp/test bench.c glibc.c openbsd.c bespoke.c | |
// | |
// the various *_strlcpy functions are placed into their own | |
// file/translation-unit so that the compiler doesn't do any inlining or | |
// const-propogation, skewing the benchmark. | |
// for this reason LTO is also NOT enabled. | |
// | |
// -fno-builtin is so that bespoke_strlcpy doesn't get "optimized" down to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -march=x86-64-v3 -O3 -o bench bench.c | |
// src taken from: https://github.com/skeeto/branchless-utf8/blob/master/test/benchmark.c | |
#define _POSIX_C_SOURCE 200112L | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <signal.h> | |
#include <stddef.h> | |
#include <unistd.h> // alarm() |