マルチスレッドプログラミング相談室 その2
■ このスレッドは過去ログ倉庫に格納されています
0046デフォルトの名無しさん
NGNG#include <unistd.h>
#include <sys/time.h>
static void no_exception() { }
static void use_exception() { try { throw 0; } catch (...) { } }
static void eval(void (*p)()) {
timeval before, after, r;
gettimeofday(&before, NULL);
for (int i = 0; i < 100000; i++) {
p(); p(); p(); p(); p(); p(); p(); p(); p(); p();
}
gettimeofday(&after, NULL);
timersub(&after, &before, &r);
printf("%ld.%03ld\n", r.tv_sec, r.tv_usec / 1000L);
}
int main() {
eval(no_exception);
eval(use_exception);
return 0;
}
Athlon 1.4GHz g++ 2.96 -O2
0.004
5.579
■ このスレッドは過去ログ倉庫に格納されています