2013-02-13 381 views
0

我不确定为什么当我尝试编译此代码时出现“GetClickCount标识符未找到”的错误。 (我得到与GetClickCount64相同的错误)。我希望有人能够解释。我的大部分问题似乎都表明代码缺少#include,但这显然不是我的问题。GetTickCount()标识符未找到

#include <Windows.h> 
#include "stdafx.h" 
#include "InSort.h" 
#include "DataSet.h" 

using namespace std; 
using namespace System; 

ref class Test 
{ 
public: 

    Test(){} 

    // TestInsertSortProcedure() method tests the InsertSort process for the duration 
    // of the sorting proceedure by checking the time prior to and after the SortCollection() 
    // method has run on five different lengths of the array being sorted, each subsequent length 
    // being 10-fold greater than the previous length 
    void TestInsertSortProcedure() 
    { 
     int start; 
     int finish; 
     int total; 
     unsigned int increment; 
     InSort<int>^ myInsertSorter = gcnew InSort<int>(); 

     for (increment = 1; increment < 1000000; increment = increment * 10) 
     { 
      // get new dataset with new number of elements equal to increment value 
      Dataset^ myDataArray = gcnew Dataset(increment); 

      // Timestamp prior to sorting: 
      start = GetTickCount(); 

      // Sort collection 
      myInsertSorter->SortCollection(myDataArray->unsortedArray); 

      // Timestamp at completion of sorting 
      finish = GetTickCount(); 
      total = finish - start; 

      // Print result to console 
      Console::WriteLine(L"Sorting time in milliseconds was: " + total); 
     } 
    } 
}; 

int main(array<System::String ^> ^args) 
{ 
Test^ testing = gcnew Test(); 
testing->TestInsertSortProcedure(); 

return 0; 
} 
+0

什么是GetTickCount的尝试()?你在寻找Environment :: TickCount吗? – Pete 2013-02-13 21:05:00

+0

嗯,我认为这是一种在MS中返回系统时间的方法。虽然我并没有被卡住,但我只是想弄清楚如何计算这种排序方法,以便最终绘制O(n^2)(以及其他排序方法)的图形。 – deadEddie 2013-02-13 21:23:22

+0

所以,是的,Environment :: TickCount正是我​​所期待的。在这里作为答案拍了数据并认为它接受:) – deadEddie 2013-02-13 21:44:17

回答

1

使用Environment::TickCount

+0

你达人!!!正是我想要做的。 – deadEddie 2013-02-13 21:54:14