예외를 처리하기 위해 여러가지 방법이 있는데, C++에서 표준으로 제공하는 try-throw-catch가 있다. 그러나 이 방법은 exception을 처리하기 위해 갖가지 삽질을 내부적으로 하는 것으로 매우 느리다는게 잘 알려져 있다. 그래도 얼마나 느린지 알고 싶었다. 그래서 do {} while (false)와 비교해보기로 했다. #include <exception> #include <iostream> #include <sys/time.h> using namespace std; static size_t gTestCount(100000); typedef long long ts_t; ts_t getTimestamp(void) { static __thread struct timeval tv; gettimeofday(&tv, NULL); return 1000000LL * tv.tv_sec + tv.tv_usec; } inline void funcDOWHILE(void) { static __thread size_t i(0); do { ++i; if ( i%2 ) break; return; } while (false); ++i; return; } inline void funcEXCEPTION(void) { static __thread size_t i(0); static exception _e; try { ++i; if ( i%2 ) throw(exception()); } catch(const exception&) { ++i; } return; } int main(int argc, char* argv[]) { ts_t t1, t2, diff; t1 = getTimestamp(); ...