C++ (Qt)void Widget::on_test2_clicked(){ std::vector<int> tmp; int i = 0; tmp.resize(1000000); std::vector<int>::iterator it = tmp.begin(); QTime timer; timer.start(); for (int m = 0; m < 10000; ++m) { for(; it != tmp.end(); ++it) { (*it) = i + 1; ++i; } it = tmp.begin(); for(; it != tmp.end(); ++it) { i = (*it); } } ui->label_2->setText(QString::number(timer.elapsed())); } void Widget::on_pushButton_clicked(){ std::vector<int> tmp; int j = 0; tmp.resize(1000000); QTime timer; timer.start(); for (int m = 0; m < 10000; ++m) { size_t i = 0; for (; i < 1000000; ++i) { tmp[i] = j + 1; ++j; } i = 0; for (; i < 1000000; ++i) { j = tmp[i]; } } ui->label->setText(QString::number(timer.elapsed()));}