Testing performance from http://blog.csdn.net/undead/article/details/6447339
Compile and install the shared object libfasttime.c
gcc -fPIC -shared -m64 -o libfasttime.so-64 libfasttime.c -ldl -lrt -lm
gcc -fPIC -shared -o libfasttime.so-32 libfasttime.c -ldl -lrt -lm
mv libfasttime.so-64 /opt/local/lib/amd64/libfasttime.so
mv libfasttime.so-32 /opt/local/lib/libfasttime.so
Compile test-time.c
gcc -o test-time test-time.c
# unset LD_PRELOAD
# dtrace -n 'syscall::gtime:entry /pid == $target/ { @[probefunc] = count(); }' -c ./test-time
dtrace: description 'syscall::gtime:entry ' matched 1 probe
dtrace: pid 26204 has exited
gtime 5000000
# ptime ./test-time
real 1.732187527
user 0.988937693
sys 0.733504670
# export LD_PRELOAD=libfasttime.so
# dtrace -n 'syscall::gtime:entry /pid == $target/ { @[probefunc] = count(); }' -c ./test-time
dtrace: description 'syscall::gtime:entry ' matched 1 probe
dtrace: pid 32725 has exited
gtime 2334
# ptime ./test-time
real 2.245796417
user 2.240161843
sys 0.004911160
Significantly less gtime
syscalls are fired with the library in place, but the program takes longer to execute...