我有2个问题。一个基本的物流和一个"为什么?!"
首先!
high_resolution_clock::time_point t1 = high_resolution_clock::now();
for (int i = 1; i < count; i++) {a.prepend(i);}
high_resolution_clock::time_point t2 = high_resolution_clock::now();
duration<double, milli> time_span = t2 - t1;
cout << "It took me " << time_span.count() << " XXXX to run this "
究竟是什么回归?我想这是秒,但它告诉我4秒钟的程序几乎立即执行。
现在,这个大问题。我试图获得一系列功能的运行时间,全部运行时间为1/10/100/10000/100000次。显然它会逐渐变大。
但如果我自己运行一个功能,我会立即得到这样的时间(不是在5秒内)..
Add at i
It took me 0.000471 seconds to run this 1 times.
It took me 0.005088 seconds to run this 10 times.
It took me 0.017778 seconds to run this 100 times.
It took me 0.151778 seconds to run this 1000 times.
It took me 1.25263 seconds to run this 10000 times.
It took me 3.97601 seconds to run this 100000 times.
如果我先运行2或3个其他功能,它会在25秒后给我这个。
Add at i
It took me 5.2e-05 seconds to run this 1 times.
It took me 0.000781 seconds to run this 10 times.
It took me 0.022803 seconds to run this 100 times.
It took me 2.15357 seconds to run this 1000 times.
It took me 205.209 seconds to run this 10000 times.
It took me 20848.9 seconds to run this 100000 times.
有人有任何想法吗?