Skip to content

Instantly share code, notes, and snippets.

View sfc9982's full-sized avatar

Yuao Chen sfc9982

View GitHub Profile
@justgord
justgord / scoped_timer.cpp
Created January 8, 2013 09:26
C++11 scoped timer class and usage
// C++11 scoped timer class and usage
//
// an example of RAII 'resource acquisition is initialisation' idiom
// build : g++ -Wall -std=c++11 -O5 -o scoped_timer scoped_timer.cpp
//
// on linux x64 resolution of timer seems to be microseconds [ on win/VC it may be much worse ]
//
// I like this approach as it doesnt litter your existing code with garbage,
// although there might be some inaccuracy due to stack setup/pulldown of the timer class itself
//