Skip to content

Instantly share code, notes, and snippets.

View munnellg's full-sized avatar

Gary Munnelly munnellg

View GitHub Profile
@munnellg
munnellg / strtest.c
Created August 22, 2018 18:04
Benchmarking glibc's strlen function
#include <math.h>
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __MACH__
#include <sys/time.h>
#include <mach/clock.h>
@munnellg
munnellg / benchmark.cpp
Created August 22, 2018 18:02
strlen performance comparison by Rick Meyer
// Compile (on OSX/Linux) using:
// clang -o benchmark -std=c++11 -Ofast benchmark.cpp -lstdc++
// gcc -o benchmark -std=c++11 -O3 benchmark.cpp -lstdc++
#include <cstring>
#include <chrono>
#include <iostream>
#include <assert.h>
double currentTimeInSeconds()