亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? library_19.html

?? linux_c函數,linux下編程必備的
?? HTML
?? 第 1 頁 / 共 4 頁
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - Date and Time</TITLE>
<P>Go to the <A HREF="library_18.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_18.html">previous</A>, <A HREF="library_20.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_20.html">next</A> section.<P>
<H1><A NAME="SEC309" HREF="library_toc.html#SEC309" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC309">Date and Time</A></H1>
<P>
This chapter describes functions for manipulating dates and times,
including functions for determining what the current time is and
conversion between different time representations.
<P>
The time functions fall into three main categories:
<P>
<UL>
<LI>
Functions for measuring elapsed CPU time are discussed in section <A HREF="library_19.html#SEC310" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC310">Processor Time</A>.
<P>
<LI>
Functions for measuring absolute clock or calendar time are discussed in
section <A HREF="library_19.html#SEC313" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC313">Calendar Time</A>.
<P>
<LI>
Functions for setting alarms and timers are discussed in section <A HREF="library_19.html#SEC321" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC321">Setting an Alarm</A>.
</UL>
<P>
<H2><A NAME="SEC310" HREF="library_toc.html#SEC310" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC310">Processor Time</A></H2>
<P>
If you're trying to optimize your program or measure its efficiency, it's
very useful to be able to know how much <DFN>processor time</DFN> or <DFN>CPU
time</DFN> it has used at any given point.  Processor time is different from
actual wall clock time because it doesn't include any time spent waiting
for I/O or when some other process is running.  Processor time is
represented by the data type <CODE>clock_t</CODE>, and is given as a number of
<DFN>clock ticks</DFN> relative to an arbitrary base time marking the beginning
of a single program invocation.
<A NAME="IDX1346"></A>
<A NAME="IDX1347"></A>
<A NAME="IDX1348"></A>
<A NAME="IDX1349"></A>
<A NAME="IDX1345"></A>
<P>
<H3><A NAME="SEC311" HREF="library_toc.html#SEC311" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC311">Basic CPU Time Inquiry</A></H3>
<P>
To get the elapsed CPU time used by a process, you can use the
<CODE>clock</CODE> function.  This facility is declared in the header file
<TT>`time.h'</TT>.
<A NAME="IDX1350"></A>
<P>
In typical usage, you call the <CODE>clock</CODE> function at the beginning and
end of the interval you want to time, subtract the values, and then divide
by <CODE>CLOCKS_PER_SEC</CODE> (the number of clock ticks per second), like this:
<P>
<PRE>
#include &#60;time.h&#62;

clock_t start, end;
double elapsed;

start = clock();
... /* Do the work. */
end = clock();
elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
</PRE>
<P>
Different computers and operating systems vary wildly in how they keep
track of processor time.  It's common for the internal processor clock
to have a resolution somewhere between hundredths and millionths of a
second.
<P>
In the GNU system, <CODE>clock_t</CODE> is equivalent to <CODE>long int</CODE> and
<CODE>CLOCKS_PER_SEC</CODE> is an integer value.  But in other systems, both
<CODE>clock_t</CODE> and the type of the macro <CODE>CLOCKS_PER_SEC</CODE> can be
either integer or floating-point types.  Casting processor time values
to <CODE>double</CODE>, as in the example above, makes sure that operations
such as arithmetic and printing work properly and consistently no matter
what the underlying representation is.
<P>
<A NAME="IDX1351"></A>
<U>Macro:</U> int <B>CLOCKS_PER_SEC</B><P>
The value of this macro is the number of clock ticks per second measured
by the <CODE>clock</CODE> function.
<P>
<A NAME="IDX1352"></A>
<U>Macro:</U> int <B>CLK_TCK</B><P>
This is an obsolete name for <CODE>CLOCKS_PER_SEC</CODE>.  
<P>
<A NAME="IDX1353"></A>
<U>Data Type:</U> <B>clock_t</B><P>
This is the type of the value returned by the <CODE>clock</CODE> function.
Values of type <CODE>clock_t</CODE> are in units of clock ticks.
<P>
<A NAME="IDX1354"></A>
<U>Function:</U> clock_t <B>clock</B> <I>(void)</I><P>
This function returns the elapsed processor time.  The base time is
arbitrary but doesn't change within a single process.  If the processor
time is not available or cannot be represented, <CODE>clock</CODE> returns the
value <CODE>(clock_t)(-1)</CODE>.
<P>
<H3><A NAME="SEC312" HREF="library_toc.html#SEC312" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC312">Detailed Elapsed CPU Time Inquiry</A></H3>
<P>
The <CODE>times</CODE> function returns more detailed information about
elapsed processor time in a <CODE>struct tms</CODE> object.  You should
include the header file <TT>`sys/times.h'</TT> to use this facility.
<A NAME="IDX1355"></A>
<P>
<A NAME="IDX1356"></A>
<U>Data Type:</U> <B>struct tms</B><P>
The <CODE>tms</CODE> structure is used to return information about process
times.  It contains at least the following members:
<P>
<DL COMPACT>
<DT><CODE>clock_t tms_utime</CODE>
<DD>This is the CPU time used in executing the instructions of the calling
process.
<P>
<DT><CODE>clock_t tms_stime</CODE>
<DD>This is the CPU time used by the system on behalf of the calling process.
<P>
<DT><CODE>clock_t tms_cutime</CODE>
<DD>This is the sum of the <CODE>tms_utime</CODE> values and the <CODE>tms_cutime</CODE>
values of all terminated child processes of the calling process, whose
status has been reported to the parent process by <CODE>wait</CODE> or
<CODE>waitpid</CODE>; see section <A HREF="library_23.html#SEC407" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC407">Process Completion</A>.  In other words, it represents
the total CPU time used in executing the instructions of all the terminated
child processes of the calling process.
<P>
<DT><CODE>clock_t tms_cstime</CODE>
<DD>This is similar to <CODE>tms_cutime</CODE>, but represents the total CPU time
used by the system on behalf of all the terminated child processes of the
calling process.
</DL>
<P>
All of the times are given in clock ticks.  These are absolute values; in a
newly created process, they are all zero.  See section <A HREF="library_23.html#SEC405" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC405">Creating a Process</A>.
<P>
<A NAME="IDX1357"></A>
<U>Function:</U> clock_t <B>times</B> <I>(struct tms *<VAR>buffer</VAR>)</I><P>
The <CODE>times</CODE> function stores the processor time information for
the calling process in <VAR>buffer</VAR>.
<P>
The return value is the same as the value of <CODE>clock()</CODE>: the elapsed
real time relative to an arbitrary base.  The base is a constant within a
particular process, and typically represents the time since system
start-up.  A value of <CODE>(clock_t)(-1)</CODE> is returned to indicate failure.
<P>
<STRONG>Portability Note:</STRONG> The <CODE>clock</CODE> function described in
section <A HREF="library_19.html#SEC311" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC311">Basic CPU Time Inquiry</A>, is specified by the ANSI C standard.  The
<CODE>times</CODE> function is a feature of POSIX.1.  In the GNU system, the
value returned by the <CODE>clock</CODE> function is equivalent to the sum of
the <CODE>tms_utime</CODE> and <CODE>tms_stime</CODE> fields returned by
<CODE>times</CODE>.
<P>
<H2><A NAME="SEC313" HREF="library_toc.html#SEC313" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC313">Calendar Time</A></H2>
<P>
This section describes facilities for keeping track of dates and times
according to the Gregorian calendar.
<A NAME="IDX1359"></A>
<A NAME="IDX1360"></A>
<A NAME="IDX1358"></A>
<P>
There are three representations for date and time information:
<P>
<UL>
<LI>
<DFN>Calendar time</DFN> (the <CODE>time_t</CODE> data type) is a compact 
representation, typically giving the number of seconds elapsed since
some implementation-specific base time.
<A NAME="IDX1361"></A>
<P>
<LI>
There is also a <DFN>high-resolution time</DFN> representation (the <CODE>struct
timeval</CODE> data type) that includes fractions of a second.  Use this time
representation instead of ordinary calendar time when you need greater
precision.
<A NAME="IDX1362"></A>
<P>
<LI>
<DFN>Local time</DFN> or <DFN>broken-down time</DFN> (the <CODE>struct
tm</CODE> data type) represents the date and time as a set of components
specifying the year, month, and so on, for a specific time zone.
This time representation is usually used in conjunction with formatting
date and time values.
<A NAME="IDX1364"></A>
<A NAME="IDX1363"></A>
</UL>
<P>
<H3><A NAME="SEC314" HREF="library_toc.html#SEC314" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC314">Simple Calendar Time</A></H3>
<P>
This section describes the <CODE>time_t</CODE> data type for representing
calendar time, and the functions which operate on calendar time objects.
These facilities are declared in the header file <TT>`time.h'</TT>.
<A NAME="IDX1365"></A>
<A NAME="IDX1366"></A>
<P>
<A NAME="IDX1367"></A>
<U>Data Type:</U> <B>time_t</B><P>
This is the data type used to represent calendar time.  In the GNU C
library and other POSIX-compliant implementations, <CODE>time_t</CODE> is
equivalent to <CODE>long int</CODE>.  When interpreted as an absolute time
value, it represents the number of seconds elapsed since 00:00:00 on
January 1, 1970, Coordinated Universal Time.  (This date is sometimes
referred to as the <DFN>epoch</DFN>.)
<P>
In other systems, <CODE>time_t</CODE> might be either an integer or
floating-point type.
<P>
<A NAME="IDX1368"></A>
<U>Function:</U> double <B>difftime</B> <I>(time_t <VAR>time1</VAR>, time_t <VAR>time0</VAR>)</I><P>
The <CODE>difftime</CODE> function returns the number of seconds elapsed
between time <VAR>time1</VAR> and time <VAR>time0</VAR>, as a value of type
<CODE>double</CODE>.  
<P>
In the GNU system, you can simply subtract <CODE>time_t</CODE> values.  But on
other systems, the <CODE>time_t</CODE> data type might use some other encoding
where subtraction doesn't work directly.
<P>
<A NAME="IDX1369"></A>
<U>Function:</U> time_t <B>time</B> <I>(time_t *<VAR>result</VAR>)</I><P>
The <CODE>time</CODE> function returns the current time as a value of type
<CODE>time_t</CODE>.  If the argument <VAR>result</VAR> is not a null pointer, the
time value is also stored in <CODE>*<VAR>result</VAR></CODE>.  If the calendar 
time is not available, the value <CODE>(time_t)(-1)</CODE> is returned.
<P>
<H3><A NAME="SEC315" HREF="library_toc.html#SEC315" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC315">High-Resolution Calendar</A></H3>
<P>
The <CODE>time_t</CODE> data type used to represent calendar times has a 
resolution of only one second.  Some applications need more precision.
<P>
So, the GNU C library also contains functions which are capable of
representing calendar times to a higher resolution than one second.  The
functions and the associated data types described in this section are
declared in <TT>`sys/time.h'</TT>.
<A NAME="IDX1370"></A>
<P>
<A NAME="IDX1371"></A>
<U>Data Type:</U> <B>struct timeval</B><P>
The <CODE>struct timeval</CODE> structure represents a calendar time.  It
has the following members:
<P>
<DL COMPACT>
<DT><CODE>long int tv_sec</CODE>
<DD>This represents the number of seconds since the epoch.  It is equivalent
to a normal <CODE>time_t</CODE> value.
<P>
<DT><CODE>long int tv_usec</CODE>
<DD>This is the fractional second value, represented as the number of
microseconds.
<P>
Some times struct timeval values are user for time intervals.  Then the
<CODE>tv_sec</CODE> member is the number of seconds in the interval, and
<CODE>tv_usec</CODE> is the number of addictional microseconds.
</DL>
<P>
<A NAME="IDX1372"></A>
<U>Data Type:</U> <B>struct timezone</B><P>
The <CODE>struct timezone</CODE> structure is used to hold minimal information
about the local time zone.  It has the following members:
<P>
<DL COMPACT>
<DT><CODE>int tz_minuteswest</CODE>
<DD>This is the number of minutes west of GMT.
<P>
<DT><CODE>int tz_dsttime</CODE>
<DD>If nonzero, daylight savings time applies during some part of the year.
</DL>
<P>
It is often necessary to subtract two values of type <CODE>struct
timeval</CODE>.  Here is the best way to do this.  It works even on some
peculiar operating systems where the <CODE>tv_sec</CODE> member has an
unsigned type.
<P>
<PRE>
/* Subtract the `struct timeval' values X and Y,
   storing the result in RESULT.
   Return 1 if the difference is negative, otherwise 0.  */

int
timeval_subtract (result, x, y)
     struct timeval *result, *x, *y;
{
  /* Perform the carry for the later subtraction by updating y. */
  if (x-&#62;tv_usec &#60; y-&#62;tv_usec) {
    int nsec = (y-&#62;tv_usec - x-&#62;tv_usec) / 1000000 + 1;
    y-&#62;tv_usec -= 1000000 * nsec;
    y-&#62;tv_sec += nsec;
  }
  if (x-&#62;tv_usec - y-&#62;tv_usec &#62; 1000000) {
    int nsec = (y-&#62;tv_usec - x-&#62;tv_usec) / 1000000;
    y-&#62;tv_usec += 1000000 * nsec;
    y-&#62;tv_sec -= nsec;
  }

  /* Compute the time remaining to wait.
     <CODE>tv_usec</CODE> is certainly positive. */
  result-&#62;tv_sec = x-&#62;tv_sec - y-&#62;tv_sec;
  result-&#62;tv_usec = x-&#62;tv_usec - y-&#62;tv_usec;

  /* Return 1 if result is negative. */
  return x-&#62;tv_sec &#60; y-&#62;tv_sec;
}
</PRE>
<P>
<A NAME="IDX1373"></A>
<U>Function:</U> int <B>gettimeofday</B> <I>(struct timeval *<VAR>tp</VAR>, struct timezone *<VAR>tzp</VAR>)</I><P>
The <CODE>gettimeofday</CODE> function returns the current date and time in the
<CODE>struct timeval</CODE> structure indicated by <VAR>tp</VAR>.  Information about the
time zone is returned in the structure pointed at <VAR>tzp</VAR>.  If the <VAR>tzp</VAR>
argument is a null pointer, time zone information is ignored.
<P>
The return value is <CODE>0</CODE> on success and <CODE>-1</CODE> on failure.  The
following <CODE>errno</CODE> error condition is defined for this function:
<P>
<DL COMPACT>
<DT><CODE>ENOSYS</CODE>
<DD>The operating system does not support getting time zone information, and
<VAR>tzp</VAR> is not a null pointer.  The GNU operating system does not
support using <CODE>struct timezone</CODE> to represent time zone
information.  Use <CODE>tzname</CODE> et al instead.  <STRONG>Say something
more helpful here.</STRONG>
</DL>
<P>
<A NAME="IDX1374"></A>
<U>Function:</U> int <B>settimeofday</B> <I>(const struct timeval *<VAR>tp</VAR>, const struct timezone *<VAR>tzp</VAR>)</I><P>
The <CODE>settimeofday</CODE> function sets the current date and time
according to the arguments.  As for <CODE>gettimeofday</CODE>, time zone
information is ignored if <VAR>tzp</VAR> is a null pointer.
<P>
You must be a privileged user in order to use <CODE>settimeofday</CODE>.
<P>
The return value is <CODE>0</CODE> on success and <CODE>-1</CODE> on failure.  The
following <CODE>errno</CODE> error conditions are defined for this function:
<P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产影片| 一区视频在线播放| 国产精品网友自拍| 亚洲国产精品欧美一二99| 久草在线在线精品观看| 91久久免费观看| 国产欧美视频一区二区三区| 亚洲va在线va天堂| 91一区二区三区在线观看| 欧美不卡激情三级在线观看| 亚洲综合丁香婷婷六月香| 国产精品自拍毛片| 日韩欧美亚洲国产精品字幕久久久| 亚洲欧美日韩综合aⅴ视频| 国产一区二区三区综合| 3atv一区二区三区| 午夜不卡av在线| 欧美在线一区二区三区| 亚洲欧洲精品一区二区精品久久久| 久久国产夜色精品鲁鲁99| 欧美福利视频导航| 亚洲国产美国国产综合一区二区| bt7086福利一区国产| 国产精品人人做人人爽人人添| 久久成人久久爱| 日韩欧美一区二区久久婷婷| 亚洲图片自拍偷拍| 在线观看日韩高清av| 亚洲精品欧美专区| 色婷婷精品久久二区二区蜜臀av| 国产精品三级av在线播放| 成人av电影在线观看| 中文字幕成人av| 欧美日韩日本视频| 亚洲一二三四在线观看| 欧美亚洲综合一区| 日韩电影免费在线观看网站| 91精品国产综合久久久蜜臀图片| 日韩国产高清影视| 欧美xxxxx裸体时装秀| 黑人精品欧美一区二区蜜桃| 久久久精品中文字幕麻豆发布| 国产在线一区观看| 国产精品麻豆欧美日韩ww| 99re8在线精品视频免费播放| 国产精品麻豆久久久| 在线观看91视频| 日韩精品电影在线| 久久欧美中文字幕| 99精品国产视频| 亚洲国产日韩综合久久精品| 制服丝袜亚洲播放| 亚洲精品国产精品乱码不99 | 日本一区二区视频在线观看| 国产精品羞羞答答xxdd| 亚洲视频狠狠干| 欧美三级视频在线播放| 六月丁香婷婷久久| 中文字幕一区二区三| 欧美四级电影网| 国产一区二区三区在线看麻豆| 中文字幕第一区二区| 欧美在线你懂得| 国产一区二区三区久久久 | 亚洲欧美日韩国产中文在线| 欧美色男人天堂| 久久99精品一区二区三区| 中文在线一区二区| 欧美日韩精品三区| 国产精品一区二区91| 一区二区三区四区蜜桃 | 欧美日韩视频在线一区二区| 免费观看在线色综合| 中文字幕制服丝袜成人av| 精品婷婷伊人一区三区三| 国产美女精品一区二区三区| 亚洲在线视频网站| 亚洲国产精品成人综合色在线婷婷| 欧美色网一区二区| 99久久久精品| 中文字幕欧美国产| 国产精品自拍三区| 另类欧美日韩国产在线| 国产精品理伦片| 欧美一区在线视频| 日本黄色一区二区| 国产91在线|亚洲| 日韩影院免费视频| 亚洲精品免费播放| 国产精品伦理在线| 亚洲精品在线观看视频| 欧美日韩国产系列| 欧美在线色视频| 白白色亚洲国产精品| 国产一区二区三区四| 亚洲福利视频一区| 亚洲精品视频在线观看网站| 中文欧美字幕免费| 国产欧美视频一区二区三区| 日韩女优制服丝袜电影| 91麻豆精品久久久久蜜臀| 色哟哟一区二区| av在线一区二区| 国产精品123区| 国产麻豆精品theporn| 久久av中文字幕片| 老司机精品视频导航| 丝袜亚洲另类丝袜在线| 亚洲一区二区三区四区不卡| 亚洲色图丝袜美腿| 亚洲欧美一区二区三区国产精品| 国产精品三级久久久久三级| 国产女主播在线一区二区| 欧美激情一区在线| 国产精品欧美经典| 自拍偷自拍亚洲精品播放| 亚洲色图色小说| 亚洲精品国久久99热| 亚洲综合丁香婷婷六月香| 亚洲一区在线免费观看| 亚洲va欧美va人人爽| 午夜影院久久久| 日本不卡123| 狠狠色丁香婷婷综合久久片| 精品一区二区av| 成人动漫中文字幕| 欧美在线视频不卡| 91精品国产乱| 久久精品网站免费观看| 国产欧美精品一区aⅴ影院| 亚洲欧美在线另类| 夜夜爽夜夜爽精品视频| 日本免费新一区视频| 麻豆精品国产91久久久久久| 国产精品自拍在线| 色偷偷久久一区二区三区| 欧美亚洲国产bt| 日韩欧美久久久| 亚洲国产精品传媒在线观看| 亚洲女与黑人做爰| 天堂在线亚洲视频| 国产成人亚洲综合a∨婷婷| 99久久综合国产精品| 欧美人与性动xxxx| 久久精品亚洲一区二区三区浴池| 国产精品久久久一本精品 | 国产清纯在线一区二区www| 中文字幕一区二区三区av| 首页国产欧美久久| 国产成人在线免费观看| 欧美日韩在线一区二区| 欧美精品一区二区三区高清aⅴ| 国产精品成人在线观看| 日本不卡在线视频| 99久久伊人网影院| 日韩精品一区二区三区蜜臀| 中文字幕亚洲综合久久菠萝蜜| 亚洲成av人片一区二区三区| 国产成人精品影视| 欧美蜜桃一区二区三区| 国产精品女同互慰在线看| 五月天丁香久久| 9人人澡人人爽人人精品| 91麻豆精品国产| √…a在线天堂一区| 美国十次综合导航| 欧洲精品中文字幕| 国产嫩草影院久久久久| 三级久久三级久久久| 欧美日韩色综合| 日韩毛片高清在线播放| 激情六月婷婷综合| 欧美人动与zoxxxx乱| 国产精品不卡在线观看| 国产一区二区三区久久久 | 亚洲另类在线一区| 国产九九视频一区二区三区| 69av一区二区三区| 亚洲欧美日韩小说| 国产a视频精品免费观看| 日韩欧美国产电影| 石原莉奈在线亚洲二区| 色94色欧美sute亚洲线路一久| 中文字幕av不卡| 国产成人在线免费| 久久嫩草精品久久久精品一| 美女任你摸久久| 91精品国产欧美一区二区成人| 亚洲精品乱码久久久久久久久| 成人午夜在线免费| 国产亚洲欧美在线| 国产一区二区在线电影| 日韩欧美在线一区二区三区| 五月天激情综合| 在线不卡a资源高清| 日韩有码一区二区三区| 制服丝袜亚洲网站| 蜜桃av一区二区在线观看| 在线播放视频一区| 日韩二区在线观看|