C++ 以纳秒为单位计算时间的代码

C++ 以纳秒为单位计算时间的代码,c++,C++,我有以下代码 #include <iostream> #include <time.h> #include <stdlib.h> #include <stdio.h> int main(){ //nanoseconds int x,y; x=6700; y=10000; int z=0; clock_t t =clock(); while (y!=0){ z+=x<

我有以下代码

#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>

int main(){

    //nanoseconds
    int x,y;
    x=6700;
    y=10000;
    int z=0;
    clock_t t =clock();

    while (y!=0){
        z+=x<<2;
        x=x>>2;

        y>>=2;
    }
    t=clock()-t;
    t=1000*t/CLOCKS_PER_TICK;
    printf("%d\n",t);
}

<>但我读到C++中存在这样的关键词

< p>我相信你在寻找。

< P>你想的是时钟,PysSEC[/P>] P>甚至谷歌知道这个答案:

你的意思是:时钟每秒

1>c:\users\david\documents\visual studio 2010\projects\nano_seconds\nano_seconds.cpp(20): error C2065: 'CLOCKS_PER_TICK' : undeclared identifier