Skip to content

Instantly share code, notes, and snippets.

@shteou
Created February 13, 2012 23:34
Show Gist options
  • Select an option

  • Save shteou/1821470 to your computer and use it in GitHub Desktop.

Select an option

Save shteou/1821470 to your computer and use it in GitHub Desktop.
Wirehair modification benchmarks
[stew@ks381068 wirehair]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.6-20120120/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --disable-multilib --disable-libssp --enable-checking=release
Thread model: posix
gcc version 4.6.2 20120120 (prerelease) (GCC)
-------------------------------------------------
./compile
g++ -D NDEBUG -O2 -lrt *.cpp
-------------------------------------------------
Cat's original version (git HEAD), no modifications
[stew@ks381068 wirehair]$ time ./cat_git_head.exe
real 0m15.539s
user 0m15.473s
sys 0m0.028s
[stew@ks381068 wirehair]$ time ./cat_git_head.exe
real 0m15.598s
user 0m15.521s
sys 0m0.040s
[stew@ks381068 wirehair]$ time ./cat_git_head.exe
real 0m15.538s
user 0m15.461s
sys 0m0.040s
-------------------------------------------------
Cat's original version, all call-sites replaced with inline function call.
[stew@ks381068 wirehair]$ time ./cat_inline_function.exe
real 0m15.616s
user 0m15.545s
sys 0m0.020s
[stew@ks381068 wirehair]$ time ./cat_inline_function.exe
real 0m15.660s
user 0m15.533s
sys 0m0.024s
[stew@ks381068 wirehair]$ time ./cat_inline_function.exe
real 0m15.561s
user 0m15.497s
sys 0m0.028s
-------------------------------------------------
Dad's version, all call-sites replaced with inline function call.
[stew@ks381068 wirehair]$ time ./dad_inline_function.exe
real 0m15.702s
user 0m15.629s
sys 0m0.032s
[stew@ks381068 wirehair]$ time ./dad_inline_function.exe
real 0m15.694s
user 0m15.633s
sys 0m0.024s
[stew@ks381068 wirehair]$ time ./dad_inline_function.exe
real 0m15.702s
user 0m15.653s
sys 0m0.012s
-------------------------------------------------
Cat's original version, all call-sites replaced with CAT_INLINE function call
[stew@ks381068 wirehair]$ time ./cat_CAT_INLINE_function.exe
real 0m16.709s
user 0m16.641s
sys 0m0.020s
[stew@ks381068 wirehair]$ time ./cat_CAT_INLINE_function.exe
real 0m16.682s
user 0m16.597s
sys 0m0.036s
[stew@ks381068 wirehair]$ time ./cat_CAT_INLINE_function.exe
real 0m16.867s
user 0m16.781s
sys 0m0.040s
-------------------------------------------------
Dad's version, all callsites replaced with CAT_INLINE function call
[stew@ks381068 wirehair]$ time ./dad_CAT_INLINE_function.exe
real 0m15.852s
user 0m15.769s
sys 0m0.020s
[stew@ks381068 wirehair]$ time ./dad_CAT_INLINE_function.exe
real 0m15.845s
user 0m15.733s
sys 0m0.056s
[stew@ks381068 wirehair]$ time ./dad_CAT_INLINE_function.exe
real 0m15.892s
user 0m15.669s
sys 0m0.036s
-------------------------------------------------
./compile
g++ -D NDEBUG -O3 -lrt *.cpp
-------------------------------------------------
Cat's original version (git HEAD), no modifications
[stew@ks381068 wirehair]$ time ./cat_git_head_O3.exe
real 0m15.566s
user 0m15.497s
sys 0m0.024s
[stew@ks381068 wirehair]$ time ./cat_git_head_O3.exe
real 0m15.544s
user 0m15.481s
sys 0m0.020s
[stew@ks381068 wirehair]$ time ./cat_git_head_O3.exe
real 0m15.568s
user 0m15.509s
sys 0m0.016s
-------------------------------------------------
Cat's version, all callsites replaced with CAT_INLINE function call
[stew@ks381068 wirehair]$ time ./cat_CAT_INLINE_function_O3.exe
real 0m15.623s
user 0m15.545s
sys 0m0.040s
[stew@ks381068 wirehair]$ time ./cat_CAT_INLINE_function_O3.exe
real 0m15.581s
user 0m15.509s
sys 0m0.032s
[stew@ks381068 wirehair]$ time ./cat_CAT_INLINE_function_O3.exe
real 0m15.588s
user 0m15.529s
sys 0m0.020s
-------------------------------------------------
Dad's version, all callsites replaced with CAT_INLINE function call (This is the best version I could find, it seems to optimise particularly well with O3)
[stew@ks381068 wirehair]$ time ./dad_CAT_INLINE_function_O3.exe
real 0m13.281s
user 0m13.213s
sys 0m0.032s
[stew@ks381068 wirehair]$ time ./dad_CAT_INLINE_function_O3.exe
real 0m13.283s
user 0m13.225s
sys 0m0.020s
[stew@ks381068 wirehair]$ time ./dad_CAT_INLINE_function_O3.exe
real 0m13.284s
user 0m13.237s
sys 0m0.012s
-------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment