当我尝试编译此代码时,我不确定为什么会收到错误“找不到GetClickCount标识符”。 (我在GetClickCount64中得到了同样的错误)。我希望有人能够解释。关于问题的大多数问题似乎表明代码缺少#include,但这显然不是我的问题。
#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 :(得分:1)
尝试使用Environment::TickCount