Skip to content

Instantly share code, notes, and snippets.

View ryanberthold's full-sized avatar

Ryan Berthold ryanberthold

View GitHub Profile
@ryanberthold
ryanberthold / timegm.c
Created May 8, 2013 23:35
Portability test for timegm replacements. One version is the classic non-thread-safe TZ+mktime, while the other is thread-safe mktime+tm_yday.
/*
gcc -Wall -pedantic -std=c99 -O2 -o timegm timegm.c
Test manual epoch calculation with tm_yday vs TZ+mktime.
On Linux, gcc 4.4.7, the manual method is ~5x faster.
Usage:
./timegm
<ctrl-C> to quit