#include <iostream>
#include <cstdio>
#include <ctime>
using namespace std;
void funcPrint();
void funcIO();
double d =1.;
void testDump(void (*func)(void))
{
int i=0;
for(i=0;i<1000000;i++)
{
d *= 0.999;
func();
}
}
int main( int argc, const char *argv[] ) {
void (*func)();
if(*argv[1]=='1')
{
func = funcIO;
}
else
{
func = funcPrint;
}
testDump(func);
return 0;
}
--- testSt.cc 2013-01-05 12:33:21.000000000 +0900
+++ testPt.cc 2013-01-05 12:33:09.000000000 +0900
@@ -1,11 +1,10 @@
-
-#include<iostream>
+#include<cstdio>
using namespace std;
extern double d;
-void funcIO()
+void funcPrint()
{
- cout << d;
+ printf("%g", d);
}
time ./a.out 1 > /dev/null
real 0m3.027s
user 0m3.016s
sys 0m0.004s
dをもう一つ追加
real 0m5.991s
user 0m5.952s
sys 0m0.004s
time ./a.out 0 > /dev/null
real 0m2.230s
user 0m2.208s
sys 0m0.004s
dをもう一つ追加
real 0m4.293s
user 0m4.252s
sys 0m0.004s
[0回]
PR