, so could we change the definition of the clocks_per_sec by making it larger, so that the timing is more accurate? By trying, you will find that this is not possible. In standard C/s + +, the smallest unit of timing is one millisecond.3. Date and time-related data structuresin standard C + +, we can obtain the date and time by the TM structure, which is defined in Time.h as follows:#ifndef _tm_definedstruct TM
" int main (void){Long i = 10000000L;clock_t start, finish;Double duration;/* Measure the duration of an event */printf ("Time to does%ld empty loops is", i);start = Clock ();while (i--);finish = Clock ();Duration = (double) (finish-start)/clocks_per_sec;printf ("%f seconds\n", duration);System ("pause");} On the author's machine, the results of the operation are as follows: Time to does 10000000 empty loops is 0.03000 seconds We can see that the clock timing unit is 1 milliseconds in length, an
record? Tom output Tom Current ranking1 The total number of players currently logged is 4, so the 1th to 4th place should be exported.+dam 100000 scoring record for DAM entry+bob 1200000 update BOB's scoring record+adam 900000 update ADAM's score record (even worse than the original)+frank 12340000 join FRANK's scoring record+leo 9000000 joins LEO's scoring record+kaine 9000000 add to KAINE score record+grace 8000000 join GRACE's scoring record+walt 9000000 add to WALT score record+sandy 800000
a loop or how much time it takes to handle other events:
Copy Code code as follows:
#include "stdio.h"
#include "Stdlib.h"
#include "time.h"
int main (void)
{
Long i = 10000000L;
clock_t start, finish;
Double duration;
/* Measure the duration of an event/
printf ("Time to does%ld empty loops is", i);
start = Clock ();
while (i--);
finish = Clock ();
Duration = (double) (finish-start)/clocks_per_sec;
printf ("%f seconds\n", duration);
System ("pause"
Time Functions in C Language
The data structure used:Time_t is a long type that represents the machine time, which can be obtained by the time () function.
The calendar time is represented by a (char *) string. Format: Week Month day hour: minute: Second Year \ n \ 0It can be obtained by the function ctime () asctime.
The time expressed in the TM structure. The structure TM is defined as follows:Struct
10000000 empty loops is 0.03000 secondsWe can see that the clock timing unit is 1 milliseconds in length, and the accuracy of the timing is 1 milliseconds, so could we change the definition of the clocks_per_sec by making it larger, so that the timing is more accurate? By trying, you will find that this is not possible. In standard C/s + +, the smallest unit of timing is one millisecond.3. Date and time-related data structuresin standard C + +, we can obtain the date and time by the
long your machine runs a loop or how much time it takes to handle other events:
#include "stdio.h"
#include "Stdlib.h"
#include "time.h"
int main (void)
{
Long i = 10000000L;
clock_t start, finish;
Double duration;
/* Measure the duration of an event/
printf ("Time to does%ld empty loops is", i);
start = Clock ();
while (i--);
finish = Clock ();
Duration = (double) (finish-start)/clocks_per_sec;
printf ("%f seconds\n", duration);
System ("pause");
}
On the author's machine, the results of
The date and time time_t and struct TM conversions in C + +Summary:Starting from the introduction of basic concepts, this paper discusses the data structure and functions used in the operation of date and time in C/A + +, and expounds the timing, time acquisition, time calculation and display format. This article also shows you the detailed use of various functions and data structures declared in the Time.h header file through a large number of exampl
2009-12-09 20:54
Time.hSome people summed up in such a few words, is indeed a classic, their own good programming to try the effect of it,Two types:
time_t: Represents the number of seconds from 1970-01-01 00:00:00 from UTC time. Also known as the calendar.struct TM: is typically used to store local time.Several functions:
Time: Gets the time_t value of the current system times (UTC time).
CTime: Converts the time_t value to a string representing the
I. queue and shared resourcesShared resources can be accessed by multiple sessions and processes at the same time. Therefore, its access needs to be protected. In Oracle, everything except PGA includes memory, disk, CPU, table, index, and transaction. There are too many types, which are represented by the word "everything. When multiple processes or sessions operate on shared resources, a queue is required. The queue is the queue ). Different teams are required to access different shared resourc
Interactive space, these several simultaneous exist or deleteSBuddyBase.dll Interactive space, these several simultaneous exist or deleteSBuddyCall.exe Interactive space, these several simultaneous exist or deleteSBuddyFriend.dll Interactive space, these several simultaneous exist or deleteSendmms.htm with QQ MMS send this picture, deleted also will write to the registry. Standard RubbishSetupinfo.ini temporary configuration file when installing QQShareFiles.dll sharing files is of little use.
C language Time FunctionsC Standard library functions include a series of date and time processing functions, which are described in the header file. These functions are listed below. Three types are defined in the header file: time_t, struct TM, and clock_t.
C language time functions described in
Time_t time (time_t * timer );
Double difftime (time_t time1, time_t time2 );
Struct TM * gmtime (const time_t
System Environment: ubuntu10.041. Common time types under Linuxtime_t, struct TM, struct timeval, struct TIMESPEC1.1 time_t Time TypeThe time_t type is defined in Time.h:typedef long time_t;Visible, time_t is actually a long integer type. Its value is expressed as from UTC (Coordinated Universal Time) January 1, 1970 00:00 00 seconds(also known as the epoch time of the Linux system) to the current moment of the number of seconds. Because of the time_t
[, minute [, second [, microsecond [, tzinfo]): Creates a new time object, replace the attribute in the original object with the time, minute, second, And microsecond specified by the parameter (the original object remains unchanged );
Time. isoformat (): returns a string representation in the format of "HH: MM: SS;
Time. strftime (fmt): returns a custom formatted string. The details are as follows;
Example:
From datetime import * tm = time (2
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.