小编phy*_*xnj的帖子

为什么这个延迟循环在没有睡眠的几次迭代后开始运行得更快?

考虑:

#include <time.h>
#include <unistd.h>
#include <iostream>
using namespace std;

const int times = 1000;
const int N = 100000;

void run() {
  for (int j = 0; j < N; j++) {
  }
}

int main() {
  clock_t main_start = clock();
  for (int i = 0; i < times; i++) {
    clock_t start = clock();
    run();
    cout << "cost: " << (clock() - start) / 1000.0 << " ms." << endl;
    //usleep(1000);
  }
  cout << "total cost: " << …
Run Code Online (Sandbox Code Playgroud)

c++ linux performance benchmarking

71
推荐指数
1
解决办法
6808
查看次数

标签 统计

benchmarking ×1

c++ ×1

linux ×1

performance ×1