Hello d_stranz,
I don't quite understand the use of 'const'.
However I ran test 'f7' along with those already posted.
Regards
auto start_time7 = std::chrono::high_resolution_clock::now();
for (int t = 0; t < 100; t++)
{
for (int s = 0; s < 1000; s++)
f7 (1000, v);
}
auto end_time7 = std::chrono::high_resolution_clock::now();
auto time7 = end_time7 - start_time7;
d = std::chrono::duration_cast<std::chrono::microseconds>(time7).count();
std::cout << "f7 took " << (d / 100) << " microseconds.\n";
auto start_time7 = std::chrono::high_resolution_clock::now();
for (int t = 0; t < 100; t++)
{
for (int s = 0; s < 1000; s++)
f7 (1000, v);
}
auto end_time7 = std::chrono::high_resolution_clock::now();
auto time7 = end_time7 - start_time7;
d = std::chrono::duration_cast<std::chrono::microseconds>(time7).count();
std::cout << "f7 took " << (d / 100) << " microseconds.\n";
To copy to clipboard, switch view to plain text mode
#pragma GCC push_options
#pragma GCC optimize ("O0")
void MainWindow::f7(int n, std::vector<int> v) {
int k;
for (int i = 0; i < n; i++)
{
for (std::vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
{
k = *it;
//qDebug() << *it << k;
}
}
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC optimize ("O0")
void MainWindow::f7(int n, std::vector<int> v) {
int k;
for (int i = 0; i < n; i++)
{
for (std::vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
{
k = *it;
//qDebug() << *it << k;
}
}
}
#pragma GCC pop_options
To copy to clipboard, switch view to plain text mode
vector
f0 took 168825 microseconds.
f6 took 167124 microseconds.
f1 took 136416 microseconds.
f2 took 155180 microseconds reverse.
f3 took 89297.5 microseconds.
f7 took 128919 microseconds. //***
array
f4 took 71238 microseconds.
f5 took 66366.4 microseconds reverse.
vector
f0 took 168825 microseconds.
f6 took 167124 microseconds.
f1 took 136416 microseconds.
f2 took 155180 microseconds reverse.
f3 took 89297.5 microseconds.
f7 took 128919 microseconds. //***
array
f4 took 71238 microseconds.
f5 took 66366.4 microseconds reverse.
To copy to clipboard, switch view to plain text mode
Bookmarks