diff options
author | hjk <qtc-committer@nokia.com> | 2009-11-16 07:54:12 (GMT) |
---|---|---|
committer | hjk <qtc-committer@nokia.com> | 2009-11-19 12:27:37 (GMT) |
commit | 5daca044cf8d185d9a09b2ec87cba10244e425e4 (patch) | |
tree | 8c7b1db37d0cc3183e8f996bdbcd43f10c6cabb4 /tests/benchmarks/qvector/outofline.cpp | |
parent | ceec6c8cc7613b555cfe4f70c335dd4494ccc727 (diff) | |
download | Qt-5daca044cf8d185d9a09b2ec87cba10244e425e4.zip Qt-5daca044cf8d185d9a09b2ec87cba10244e425e4.tar.gz Qt-5daca044cf8d185d9a09b2ec87cba10244e425e4.tar.bz2 |
add a benchmark comparing QVector and std::vector performance
This also includes a QRawVector class template mimicing a
QVector without reference counting.
Diffstat (limited to 'tests/benchmarks/qvector/outofline.cpp')
-rw-r--r-- | tests/benchmarks/qvector/outofline.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/benchmarks/qvector/outofline.cpp b/tests/benchmarks/qvector/outofline.cpp new file mode 100644 index 0000000..d1d72b0 --- /dev/null +++ b/tests/benchmarks/qvector/outofline.cpp @@ -0,0 +1,41 @@ + +#include <QVector> +#include <vector> +#include "qrawvector.h" + +const int N = 1000000; +double s = 0; + +QVector<double> qvector_fill_and_return_helper() +{ + QVector<double> v(N); + for (int i = 0; i != N; ++i) + v[i] = i; + return v; +} + +QVector<double> qrawvector_fill_and_return_helper() +{ + QRawVector<double> v(N); + for (int i = 0; i != N; ++i) + v[i] = i; + return v.mutateToVector(); +} + +QVector<double> mixedvector_fill_and_return_helper() +{ + std::vector<double> v(N); + for (int i = 0; i != N; ++i) + v[i] = i; + return QVector<double>::fromStdVector(v); +} + + +std::vector<double> stdvector_fill_and_return_helper() +{ + std::vector<double> v(N); + for (int i = 0; i != N; ++i) + v[i] = i; + return v; +} + |