Exemple #1
0
int main(void)
{
    int i;
    u64 begin,end;
    ElemType* const array = (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    InitalArray(array);
    PrintArray(array);

    ElemType* tempArray1 =  (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    ElemType* tempArray2 =  (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    ElemType* tempArray3 =  (int*)malloc(sizeof(int)*ARRAY_NUMBER );
    for(i = 0; i < ARRAY_NUMBER ; i++)
    {
        tempArray1[i] = array[i];
        tempArray2[i] = array[i];
        tempArray3[i] = array[i];
    }

    //冒泡排序
    Rdtsc(&begin);
    BubbleSort(array);
    Rdtsc(&end);
    printf("冒泡排序后的数组是:");
    PrintArray(array);
    printf("花费时间为:%llu \n",end - begin);

    Rdtsc(&begin);
    BubbleSort2(tempArray1);
    Rdtsc(&end);
    printf("冒泡排序2后的数组是:");
    PrintArray(tempArray1);
    printf("花费时间为:%llu \n",end - begin);

    Rdtsc(&begin);
    BubbleSort3(tempArray2);
    Rdtsc(&end);
    printf("冒泡排序3后的数组是:");
    PrintArray(tempArray2);
    printf("花费时间为:%llu \n",end - begin);
    
    Rdtsc(&begin);
    BubbleSort4(tempArray3);
    Rdtsc(&end);
    printf("冒泡排序4后的数组是:");
    PrintArray(tempArray3);
    printf("花费时间为:%llu \n",end - begin);

    return 0;
}
Exemple #2
0
long long CStopwatch::Now() const
{
    return (Rdtsc() - m_nStart) / m_nFrequency;
}
Exemple #3
0
void CStopwatch::Start()
{
    m_nStart = Rdtsc();
}