struct Timeval and struct TIMESPEC

Source: Internet
Author: User

struct Timeval {      time_t tv_sec;      suseconds_t tv_usec;};



The test code is as follows:
#include <stdio.h> #include <sys/time.h> #include <time.h> int gettimeofday (struct timeval *tv, Struc  T timezone *tz);  int main (int argc,char * argv[]) {      struct timeval TV;      while (1) {            gettimeofday (&tv,null);                   printf ("Time%u:%u/n", tv.tv_sec,tv.tv_usec);          Sleep (2);       }   return 0; }


The results of the operation are as follows:
Time 1,259,471,701:970,193
Time 1,259,471,703:971,529
Time 1,259,471,705:973,225
Time 1,259,471,707:974,921
Timespec


struct timespec{    time_t tv_sec;           long int tv_nsec;      };



Unlike struct Timeval, members of the structure are transformed into nanoseconds in microseconds

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

struct Timeval and struct TIMESPEC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.