欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c語言clock函數(shù)使用示例

 更新時間:2014年04月01日 16:14:01   作者:  
這篇文章主要介紹了c語言clock函數(shù)使用示例,需要的朋友可以參考下

clock_t clock( void );
Calculates the processor time used by the calling process
head file is <time.h>

Return Value
clock returns the number of clock ticks of elapsed processor time. The returned value
is the product of the amount of time that has elapsed since the start of a process and
the value of the CLOCKS_PER_SEC constant. If the amount of elapsed time is
unavailable, the function returns –1, cast as a clock_t.

Remarks
The clock function tells how much processor time the calling process has used. The
time in seconds is approximated by dividing the clock return value by the value of the
CLOCKS_PER_SEC constant. In other words, clock returns the number of
processor timer ticks that have elapsed. A timer tick is approximately equal to
1/CLOCKS_PER_SEC second. In versions of Microsoft C before 6.0, the
CLOCKS_PER_SEC constant was called CLK_TCK.

復制代碼 代碼如下:

/* CLOCK.C: This example prompts for how long
 * the program is to run and then continuously
 * displays the elapsed time for that period.
 */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void sleep( clock_t wait );
void main( void )
{
   long    i = 600000000L;
   clock_t start, finish;
   double  duration;
   /* Delay for a specified time. */
   printf( "Delay for three seconds\n" );
   sleep( (clock_t)3 * CLOCKS_PER_SEC );
   printf( "Done!\n" );
   /* Measure the duration of an event. */
   printf( "Time to do %ld empty loops is ", i );
   start = clock();
   while( i-- )

   finish = clock();
   duration = (double)(finish - start) / CLOCKS_PER_SEC;
   printf( "%2.1f seconds\n", duration );
}
/* Pauses for a specified number of milliseconds. */
void sleep( clock_t wait )
{
   clock_t goal;
   goal = wait + clock();
   while( goal > clock() )

}//sleep

相關文章

  • 二分圖匹配實例代碼及整理

    二分圖匹配實例代碼及整理

    這篇文章主要介紹了二分圖匹配實例代碼及整理的相關資料,這里提供了三種方法包括匈牙利算法,KM算法,多重匹配,需要的朋友可以參考下
    2017-07-07
  • QT編寫簡單登錄界面的實現(xiàn)示例

    QT編寫簡單登錄界面的實現(xiàn)示例

    登陸界面是網(wǎng)頁中常見的界面,本文主要介紹了QT編寫簡單登錄界面的實現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下
    2024-02-02
  • C++中CString string char* char 之間的字符轉(zhuǎn)換(多種方法)

    C++中CString string char* char 之間的字符轉(zhuǎn)換(多種方法)

    在寫程序的時候,我們經(jīng)常遇到各種各樣的類型轉(zhuǎn)換,比如 char* CString string 之間的互相轉(zhuǎn)換,這里簡單為大家介紹一下,需要的朋友可以參考下
    2017-09-09
  • c語言尾隊列tailq使用示例分享

    c語言尾隊列tailq使用示例分享

    這篇文章主要介紹了c語言尾隊列tailq使用示例,大家參考使用吧
    2014-01-01
  • 樹形結構的3中搜索方式示例分享

    樹形結構的3中搜索方式示例分享

    樹的3中常見搜索方式,包括二叉樹方式(每一層只有0和1)、滿m叉樹(每一層都有0 到m - 1)、子集樹,也稱為全排列樹,需要的朋友可以參考下
    2014-02-02
  • C++關于引用作為函數(shù)的用法

    C++關于引用作為函數(shù)的用法

    今天小編就為大家分享一篇關于C++關于引用作為函數(shù)的用法,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-12-12
  • C語言printf詳細解析

    C語言printf詳細解析

    C中格式字符串printf()的一般形式為: %[標志][輸出最小寬度][.精度][長度]類型, 其中方括號[]中的項為可選項。各項的意義介紹如下
    2013-09-09
  • C語言基礎指針詳解教程

    C語言基礎指針詳解教程

    此處對于指針做一些簡要的介紹,作者實屬初學,寫博客也是作者學習的一個過程,難免文章中有內(nèi)容理解不到位或者有不當之處,還請朋友們不吝指正,希望大家給予支持
    2021-11-11
  • C語言獲得電腦的IP地址的小例子

    C語言獲得電腦的IP地址的小例子

    C語言獲得電腦的IP地址的小例子,需要的朋友可以參考一下
    2013-05-05
  • 哈夫曼的c語言實現(xiàn)代碼

    哈夫曼的c語言實現(xiàn)代碼

    著先通過 HuffmanTree() 函數(shù)構造哈夫曼樹,然后在主函數(shù) main()中自底向上開始(也就是從數(shù)組序號為零的結點開始)向上層層判斷,若在父結點左側,則置碼為 0,若在右側,則置碼為 1。最后輸出生成的編碼
    2013-07-07

最新評論