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

Last change on this file since 396 was 219, checked in by ansari, 26 years ago

Creation module DPC/SysTools Reza 09/04/99

File size: 1.4 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
32clock_t CPUT0, CPUT;
33time_t ELT0, ELT;
34
35void InitTim(void);
36void PrtTim(char *Comm);
37
38/* Nouvelle-Fonction */
39void InitTim(void)
40{
41CPUT0 = CPUT = clock();
42ELT0 = ELT = time(NULL);
43return;
44}
45
46/* Nouvelle-Fonction */
47void PrtTim(char *Comm)
48{
49float tcal,tcalt;
50clock_t cput;
51time_t elt;
52int etm,etmt;
53
54elt = time(NULL); cput = clock();
55tcalt = ( (float)(cput) - (float)(CPUT0) ) / (float)(CLOCKS_PER_SEC);
56tcal = ( (float)(cput) - (float)(CPUT) ) / (float)(CLOCKS_PER_SEC);
57etm = elt - ELT;
58etmt = elt - ELT0;
59printf("%s CPUTime: Total= %g (Partial= %g) Sec. \n",
60 Comm, tcalt, tcal);
61printf("ElapsedTime(hh:mm:ss): Total= %02d:%02d:%02d ",
62 etmt/3600, (etmt%3600)/60, etmt%60);
63printf(" (Partial= %02d:%02d:%02d)\n",
64 etm/3600, (etm%3600)/60, etm%60);
65
66ELT = elt;
67CPUT = cput;
68return;
69}
Note: See TracBrowser for help on using the repository browser.