source: Sophya/trunk/SophyaLib/SysTools/timing.c@ 2520

Last change on this file since 2520 was 2212, checked in by ansari, 23 years ago

Mise a jour de la documentation SysTools, Reza 15/10/2002

File size: 1.7 KB
Line 
1/* Fonction d'impression de temps de calcul et de temps passe */
2/* R.Ansari Juin 93 */
3
4/*
5++
6 Module Temps CPU, passé (C)
7 Lib LibsUtil
8 include timing.h
9
10 Fonctions permettant d'imprimer le temps CPU consommé et le temps
11 passé.
12--
13*/
14
15/*
16++
17 void InitTim()
18 Initialisation des chronomètres
19 void PrtTim(char *comm)
20 Imprime le temps CPU, et le temps passé depuis
21 le dernier appel à "PrtTim()" avec le commentaire
22 "comm". Imprime aussi le cumul du temps CPU et du
23 temps passé depuis l'appel à "InitTim()".
24--
25*/
26
27#include <stdlib.h>
28#include <stdio.h>
29#include <string.h>
30#include <time.h>
31
32#include "timing.h"
33
34static clock_t CPUT0, CPUT;
35static time_t ELT0, ELT;
36
37
38/* Nouvelle-Fonction */
39/*!
40 \ingroup SysTools
41 Initializes CPU and elapsed time timer (C function).
42 The values of the CPU and elapsed time can then be printed
43 using \b PrtTim()
44*/
45void InitTim(void)
46{
47CPUT0 = CPUT = clock();
48ELT0 = ELT = time(NULL);
49return;
50}
51
52/* Nouvelle-Fonction */
53/*!
54 \ingroup SysTools
55 Prints the values of the CPU and elapsed time, since call to \b InitTim().
56*/
57void PrtTim(const char * Comm)
58{
59float tcal,tcalt;
60clock_t cput;
61time_t elt;
62int etm,etmt;
63
64elt = time(NULL); cput = clock();
65tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC);
66tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC);
67etm = elt - ELT;
68etmt = elt - ELT0;
69printf("%s CPUTime: Total= %g (Partial= %g) Sec. \n",
70 Comm, tcalt, tcal);
71printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ",
72 etmt/3600, (etmt%3600)/60, etmt%60);
73printf(" (Partial= %02d:%02d:%02d)\n",
74 etm/3600, (etm%3600)/60, etm%60);
75
76ELT = elt;
77CPUT = cput;
78return;
79}
Note: See TracBrowser for help on using the repository browser.