如何使用C语言计算运行时间

时间:2018-12-19 18:06:58

标签: c

以下函数未编译:

double GetCurTime()
{
    LARGE_INTEGER CounterFreq;
    QueryPerformanceFrequency(&CounterFreq);

    LARGE_INTEGER Counter;
    QueryPerformanceCounter(&Counter);
    return (double)Counter.QuadPart / (double)CounterFreq.QuadPart;
}

我使用的C编译器无法识别LARGE_INTEGERQueryPerformanceFrequency

如果有人认出这些物品,您能建议我在哪里找到它们吗?
也许它们在头文件或我目前没有的库中。

1 个答案:

答案 0 :(得分:1)

包括function compareArticle() { //For timing my script $time_start = microtime(true); include '../include/write.php'; $readNewsQuery = "select title,text,articleid,name,datetoday from texts"; $readNews = $dbwrite->query($readNewsQuery); $dateToday = date("Y-m-d"); if ($readNews) { //Fetch mysql data as an array $news = $readNews->fetch_all(MYSQLI_NUM); } foreach ($news as $item) { // Decrease the sample pool if ($item[4] != $dateToday) { continue; } $strippedWords = strtolower($item[0]); $strippedWords = mb_split(' +', $strippedWords); // Start another foreach to loop through the articles to compare with foreach ($news as $compare) { $compareString = ""; $compareString .= $compare[0]; $compareString .= $compare[1]; $count = 0; // Start yet another foreach to loop through the words foreach ($strippedWords as $word) { // I only want to count the words that are longer than 4 characters if (strlen($word) > 4) { if (strpos(strtolower($compareString), $word)) { $count++; } } } 库并使用<time.h>函数。

此外,如果要使用QueryPerformanceCounter,则需要包括Winbase.h(和Windows.h)。