そんなときは、サクッと Wandbox で試してみるのですが毎回計測コードをどう書くんだっけ?となっていたのでテンプレを用意しました。
速度比較テンプレ
— ずみっくす :D (@srz_zumix) 2019年4月24日
[Wandbox]三へ( へ՞ਊ ՞)へ ハッハッ https://t.co/Qj2AQ5JqvM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://wandbox.org/permlink/DnmwABiHeYne8Iaz | |
#include <iostream> | |
#include <cstdlib> | |
#include <boost/timer/timer.hpp> | |
int main() | |
{ | |
const long n=10000000; | |
{ | |
boost::timer::cpu_timer timer; | |
for (long i = 0; i < n; ++i) { | |
// DO 1 | |
} | |
std::string result = timer.format(); | |
std::cout << result << std::endl; | |
} | |
{ | |
boost::timer::cpu_timer timer; | |
for (long i = 0; i < n; ++i) { | |
// DO 2 | |
} | |
std::string result = timer.format(); | |
std::cout << result << std::endl; | |
} | |
} |
0 件のコメント:
コメントを投稿