Eigen中数据内存访问耗时记录

    MatrixXi arr = MatrixXi::Random(450, 800);
    int h = arr.rows(); int w = arr.cols();
    time_t t0 = clock();
    for (int y=0; y 10) arr(y,x)=1;
        }
    }
    printf("time: %.2f ms\n", (float)(clock() - t0)/1000); // 37.8ms
    int* ptr = arr.data();
    t0 = clock();
    for (int x=0; x 10) *ptr = 1;
            ptr++;
        }
    }
    printf("time: %.2f ms\n", (float)(clock() - t0)/1000); // 0.9ms
    t0 = clock();
    ptr = arr.data();
    int* ptr_t;
    for (int x=0; x> arrRow(arr.data(), arr.rows(), arr.cols());
    ptr = arrRow.data();
    int s = arr.size();
    for (int y=0; y 10) *ptr = 1;
            ptr++;
    }
    printf("time: %.2f ms\n", (float)(clock() - t0)/1000); // 0.9ms

你可能感兴趣的:(Eigen中数据内存访问耗时记录)