【发布时间】:2013-02-13 21:02:44
【问题描述】:
我不确定为什么在尝试编译此代码时收到错误“GetClickCount identifier not found”。 (我得到与 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;
}
【问题讨论】:
-
什么是GetTickCount()?您在寻找 Environment::TickCount 吗?
-
好吧,我认为这是一种在 MS 中返回系统时间的方法。不过,我并没有坚持下去,我真的只是想弄清楚如何计时这种排序方法,以便我最终可以绘制 O(n^2) 的图形(以及添加它们时的其他排序方法)。
-
所以,是的,Environment::TickCount 正是我想要的。把 dat 拍在这里作为答案,并认为它被接受:)