Salut a tous,
je cherche a chronométrer l'execution d'un programme grace a des fonctions standards.
Quelqu'un a t'il des idées ?
Merci d'avance
Salut a tous,
je cherche a chronométrer l'execution d'un programme grace a des fonctions standards.
Quelqu'un a t'il des idées ?
Merci d'avance
Essayes avec la fonction C gettime (sous DOS) :
Sous linux, il existe également une fonction C : localtime
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 gettime Syntax #include <dos.h> void gettime(struct time *); Description This function gets the current time. The return structure is as follows: struct time { unsigned char ti_min; unsigned char ti_hour; unsigned char ti_hund; unsigned char ti_sec; }; See section settime. See section getdate. Return Value None. Portability not ANSI, not POSIX Example struct time t; gettime(&t);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 C Library Functions ctime(3C) NAME ctime, ctime_r, localtime, localtime_r, gmtime, gmtime_r, asctime, asctime_r, tzset, tzsetwall - convert date and time to string SYNOPSIS #include <time.h> char *ctime(const time_t *clock); struct tm *localtime(const time_t *clock); struct tm *gmtime(const time_t *clock); char *asctime(const struct tm *tm); extern time_t timezone, altzone; extern int daylight; extern char *tzname[2]; void tzset(void); void tzsetwall(void); char *ctime_r(const time_t *clock, char *buf, int buflen); struct tm *localtime_r(const time_t *clock, struct tm *res); struct tm *gmtime_r(const time_t *clock, struct tm *res); char *asctime_r(const struct tm *tm,char *buf, int buflen); POSIX cc [ flag... ] file ... -D_POSIX_PTHREAD_SEMANTICS [ library... ] char *ctime_r(const time_t *clock, char *buf); char *asctime_r(const struct tm *tm,char *buf); DESCRIPTION The ctime(), localtime(), and gmtime() functions accept arguments of type time_t, pointed to by clock(), represent- ing the time in seconds since 00:00:00 UTC, January 1, 1970. The ctime() function returns a pointer to a 26-character string as shown below. Time zone and daylight savings corrections are made before string generation. The fields are constant width: Fri Sep 13 00:00:00 1986\n\0
Avec ces fonctions, tu peux récuperer l'heure courante au début et en fin de ton programme -> une différence te donnera le temps d'execution de ton programme.
Salut.
Dans time.h tu as clock() mais ce n'est pas trés précis (sous windows je croie qu'elle te renvois l'horloge systeme donc pas plus précis que le centieme de seconde) et sous Linux elle existe mais je n'arrive pas a la faire marcher (elle me renvois toujours 0).
Parfait clock() fonctionne bien chez moi !Envoyé par sylvain114d
Merci en plus la fonction clock est ISO99 donc standard !!
Merci bien encore une fois.
A bientot
Partager