亚洲欧美第一页_禁久久精品乱码_粉嫩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在线观看| 久久国产剧场电影| 黑人巨大精品欧美一区| 裸体在线国模精品偷拍| 国产综合久久久久影院| 久久99精品国产麻豆不卡| 久久成人免费网| 国产精品99精品久久免费| 国产精品99精品久久免费| 成人免费av网站| 91黄色激情网站| 欧美日韩另类一区| 精品久久五月天| 中文成人av在线| 欧美白人最猛性xxxxx69交| 久久综合久久综合久久综合| 中文字幕精品在线不卡| 伊人婷婷欧美激情| 婷婷一区二区三区| 国产高清精品网站| 91理论电影在线观看| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 一区二区日韩av| 亚洲第一精品在线| 国产精品12区| 在线观看精品一区| 久久嫩草精品久久久精品一| 1024亚洲合集| 另类综合日韩欧美亚洲| 91免费小视频| 精品国产第一区二区三区观看体验| 久久精品日产第一区二区三区高清版 | 亚洲国产精品ⅴa在线观看| 亚洲精品欧美在线| 精品一区二区免费在线观看| 日本精品一级二级| 久久综合九色综合97婷婷女人 | 舔着乳尖日韩一区| 成人免费视频视频| 日韩欧美在线网站| 亚洲一区二区偷拍精品| 丁香天五香天堂综合| 3d动漫精品啪啪1区2区免费| 亚洲欧美综合另类在线卡通| 麻豆国产精品官网| 欧美精品第1页| 亚洲欧美在线视频观看| 激情五月激情综合网| 在线观看视频91| 国产精品乱子久久久久| 激情文学综合插| 日韩一级免费观看| 亚洲国产综合视频在线观看| jlzzjlzz欧美大全| 久久久久久久久久久久久久久99 | 91国产成人在线| 日本一区免费视频| 精品一区二区久久久| 欧美日韩国产片| 亚洲制服丝袜av| 在线观看视频欧美| 一区二区三区免费观看| 99在线热播精品免费| 国产日韩精品一区| 国产精品一区免费视频| 精品精品国产高清一毛片一天堂| 午夜一区二区三区视频| 欧美午夜一区二区三区免费大片| 亚洲视频免费看| 91麻豆成人久久精品二区三区| 亚洲欧洲另类国产综合| eeuss影院一区二区三区| 国产精品久久久久久久久免费桃花| 国产精品888| 中文字幕av不卡| 99久久亚洲一区二区三区青草| 中文字幕精品一区二区三区精品| 成人av在线网站| 中文字幕一区在线观看| 色综合视频在线观看| 亚洲一卡二卡三卡四卡五卡| 精品视频在线看| 视频一区二区三区在线| 日韩一区和二区| 国产一区欧美二区| 国产精品国产精品国产专区不蜜| 91视视频在线观看入口直接观看www | 一区二区三区加勒比av| 欧洲一区在线观看| 天堂va蜜桃一区二区三区漫画版| 日韩一区二区不卡| 国产精品一区二区视频| 国产日韩欧美一区二区三区乱码| 91在线云播放| 性感美女久久精品| 久久久久久久久久美女| 91色在线porny| 日韩精品视频网| 国产亚洲精品超碰| 91在线视频网址| 久久精品久久99精品久久| 中文字幕欧美三区| 欧美三级韩国三级日本一级| 国模少妇一区二区三区| 亚洲美女偷拍久久| 精品国产免费久久| 99精品视频一区| 久久精品国产成人一区二区三区 | 国内精品免费在线观看| 国产精品国产三级国产普通话三级| 欧美午夜视频网站| 国产一二三精品| 一区二区免费看| 国产日韩欧美激情| 欧美一级欧美三级在线观看| 成人免费精品视频| 六月婷婷色综合| 亚洲一区二区三区四区在线免费观看| 日韩精品最新网址| 欧美亚洲一区二区在线| 有码一区二区三区| 国模套图日韩精品一区二区| 日韩精品一区二区三区在线观看| 韩国av一区二区三区| 一区二区三区日韩在线观看| 久久久精品免费免费| 欧美日韩国产成人在线91| 成人免费三级在线| 久久97超碰国产精品超碰| 亚洲一区二区3| 中文字幕字幕中文在线中不卡视频| 精品久久久网站| 777色狠狠一区二区三区| 色婷婷精品久久二区二区蜜臂av| 成人亚洲精品久久久久软件| 美女脱光内衣内裤视频久久影院| 亚洲一区二区三区自拍| 中文字幕在线不卡| 国产精品美女久久久久久2018| 精品国产乱码久久久久久图片| 欧美另类高清zo欧美| 在线视频中文字幕一区二区| 成人av网站免费观看| 丁香啪啪综合成人亚洲小说| 国产九九视频一区二区三区| 日本v片在线高清不卡在线观看| 亚洲h动漫在线| 亚洲成人7777| 日韩专区一卡二卡| 丝袜诱惑制服诱惑色一区在线观看 | 成人高清免费在线播放| 国产精品自在欧美一区| 国内精品不卡在线| 国产精品资源网站| 国产一区二区三区久久久| 国产传媒一区在线| 成人性生交大片免费看中文| 成人性色生活片| 99久久综合99久久综合网站| 91免费看片在线观看| 91久久精品国产91性色tv| 在线中文字幕一区| 91精品午夜视频| 欧美va亚洲va| 日本一区二区三区四区 | 色久综合一二码| 欧美视频完全免费看| 欧美日韩国产在线播放网站| 日韩欧美中文一区| 久久一区二区视频| 亚洲视频一区二区免费在线观看| 亚洲一区二区av在线| 免费成人深夜小野草| 国产精品99久久久久久似苏梦涵| 成人激情动漫在线观看| 欧美在线观看视频在线| 精品免费国产二区三区| 中文字幕在线免费不卡| 婷婷综合另类小说色区| 国产成人精品aa毛片| 色吧成人激情小说| 日韩欧美123| 亚洲视频1区2区| 久久99深爱久久99精品| 99国产精品一区| 欧美成人精品福利| 亚洲卡通动漫在线| 狠狠色丁香婷综合久久| 色哦色哦哦色天天综合| 久久久久久一二三区| 亚洲国产一区视频| 成人中文字幕合集| 欧美一区二区三区视频免费播放| 中文字幕在线观看一区| 久久99国产精品免费| 在线观看成人免费视频| 国产色产综合色产在线视频|