Skip to content

Instantly share code, notes, and snippets.

@daniel-abramov
Created June 12, 2016 16:35
Show Gist options
  • Save daniel-abramov/2ef6fbf5ed794a506e09ba72a1692781 to your computer and use it in GitHub Desktop.
Save daniel-abramov/2ef6fbf5ed794a506e09ba72a1692781 to your computer and use it in GitHub Desktop.
#include <chrono>
#include <iostream>
#include <vector>
#include <QtCore/QVector>
template <typename container>
void test(const char* desc)
{
auto t1 = std::chrono::high_resolution_clock::now();
container c;
for (unsigned i = 0; i < 100000000; ++i)
c.push_back(i);
for (unsigned i = 0; i < 100000000; ++i)
c.pop_back();
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << desc << " " << (t2 - t1).count() << std::endl;
}
int main()
{
test< std::vector<int> >("std::vector");
test< QVector<int> >("QVector");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment