• clock_t与time_t的区别及联系


    clock_t

    <ctime>
    Clock type

    Type capable of representing clock tick counts and support arithmetical operations.

    This type is returned by the clock function of the <ctime> header to represent the number of clock ticks since the beginning of the program execution.

    time_t

    <ctime>
    Time type

    Type capable of representing times and support arithmetical operations.

    This type is returned by the time function and is used as parameter by some other functions of the <ctime> header.

    It is almost universally expected to be an integral value representing the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC. This is due to historical reasons, since it corresponds to a unix timestamp, but is widely implemented in C libraries across all platforms.

    转载:

    下面转自:http://www.cnblogs.com/chenyadong/archive/2011/12/03/2274783.html

    clock()返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元(clock tick)数,而sleep(5)并不占用cpu资源,导致start1和end1返回的值一样。time(&temp)返回从CUT(Coordinated Universal Time)时间1970年1月1日00:00:00(称为UNIX系统的Epoch时间)到当前时刻的秒数。总之,用time_t计时才是人们正常意识上的秒数,而clock_t计时所表示的是占用CPU的时钟单元。

  • 相关阅读:
    2016.5.11_经典试题-回文算法【ABAP】
    shell基础知识
    python笔记2
    python笔记1
    vmware rdm
    网页中图片显示方向与实际图片方向不一致
    vue 弹性布局 实现长图垂直居上,短图垂直居中
    IE10 解决input file 同一文件不触发onchange事件
    04. pt-deadlock-logger
    03. pt-config-diff
  • 原文地址:https://www.cnblogs.com/lixiaofei1987/p/3182098.html
Copyright © 2020-2023  润新知