[Assorted-commits] SF.net SVN: assorted: [363] sandbox/trunk/src/cc/stl_seq_bench.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-11 04:56:36
|
Revision: 363 http://assorted.svn.sourceforge.net/assorted/?rev=363&view=rev Author: yangzhang Date: 2008-02-10 20:56:41 -0800 (Sun, 10 Feb 2008) Log Message: ----------- added stl sequence benchmark Added Paths: ----------- sandbox/trunk/src/cc/stl_seq_bench.cc Added: sandbox/trunk/src/cc/stl_seq_bench.cc =================================================================== --- sandbox/trunk/src/cc/stl_seq_bench.cc (rev 0) +++ sandbox/trunk/src/cc/stl_seq_bench.cc 2008-02-11 04:56:41 UTC (rev 363) @@ -0,0 +1,33 @@ +// A simple performance benchmark for the various sequence containers. +// +// TODO: add list + +#include <deque> +#include <vector> + +#include <commons/time.h> + +using namespace std; +using namespace commons; + +template<typename T> void +doit(T xs) +{ + const int n = 1000000, t = 100; + timer timer(""); + for (int j = 0; j < t; j++) { + for (int i = 0; i < n; i++) + xs.push_back(i); + } + timer.print(); +} + +int +main() +{ + doit(deque<int>()); + doit(deque<int>()); + doit(vector<int>()); + doit(vector<int>()); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |