- /*
- Fichier chrono.h
- */
- #ifndef CHRONO_H
- #define CHRONO_H
-
- #include <stdio.h>
- #include <time.h>
-
- #if defined(__cplusplus) && __cplusplus
- extern "C" {
- #endif
-
- /* Pour s'assurer que clock_t soit bien définie */
- #ifndef _CLOCK_T_DEFINED
- typedef long clock_t;
- #define _CLOCK_T_DEFINED
- #endif
-
- static clock_t STARTCLOCK;
- static clock_t ENDCLOCK;
-
- #define StartClock() STARTCLOCK=clock();
- #define StopClock() ENDCLOCK=clock();
-
- static void ShowClock(char * prefix, short show_unformated) {
- printf("\n*****************************************************\n");
- if ( prefix != NULL ) {
- printf("-- %s --\n", prefix);
- }
- printf("Elapsed time: %4.2f\n", (double) ( ( ENDCLOCK - STARTCLOCK ) / CLOCKS_PER_SEC ));
- if ( show_unformated == 1 ) {
- printf("Unformated: %d\n", (ENDCLOCK - STARTCLOCK));
- }
- printf("*****************************************************\n");
- }
-
- #if defined(__cplusplus) && __cplusplus
- }
- #endif
-
- #endif /* Fin du fichier chrono.h */
-
-
-
-
-
-
-
- /*
-
- Comment l'utiliser !? C'est simlpe, très simple
-
- */
-
-
-
- #include <string.h>
- #include "chrono.h"
-
- int main(int argc, char* argv[]) {
-
- char machaine[50];
- int i = 0;
-
- StartClock(); /* Début */
-
- for ( ; i < 5000; i++ ) {
-
- strcpy(machaine, "une chaine a copier ici");
-
- }
-
- StopClock(); /* Fin */
- ShowClock("strcpy() test", 1); /* affiche le résultat */
-
- /* C'est tout! Simplement 3 petites lignes */
- return 0;
-
- }
-
-
-
-
/*
Fichier chrono.h
*/
#ifndef CHRONO_H
#define CHRONO_H
#include <stdio.h>
#include <time.h>
#if defined(__cplusplus) && __cplusplus
extern "C" {
#endif
/* Pour s'assurer que clock_t soit bien définie */
#ifndef _CLOCK_T_DEFINED
typedef long clock_t;
#define _CLOCK_T_DEFINED
#endif
static clock_t STARTCLOCK;
static clock_t ENDCLOCK;
#define StartClock() STARTCLOCK=clock();
#define StopClock() ENDCLOCK=clock();
static void ShowClock(char * prefix, short show_unformated) {
printf("\n*****************************************************\n");
if ( prefix != NULL ) {
printf("-- %s --\n", prefix);
}
printf("Elapsed time: %4.2f\n", (double) ( ( ENDCLOCK - STARTCLOCK ) / CLOCKS_PER_SEC ));
if ( show_unformated == 1 ) {
printf("Unformated: %d\n", (ENDCLOCK - STARTCLOCK));
}
printf("*****************************************************\n");
}
#if defined(__cplusplus) && __cplusplus
}
#endif
#endif /* Fin du fichier chrono.h */
/*
Comment l'utiliser !? C'est simlpe, très simple
*/
#include <string.h>
#include "chrono.h"
int main(int argc, char* argv[]) {
char machaine[50];
int i = 0;
StartClock(); /* Début */
for ( ; i < 5000; i++ ) {
strcpy(machaine, "une chaine a copier ici");
}
StopClock(); /* Fin */
ShowClock("strcpy() test", 1); /* affiche le résultat */
/* C'est tout! Simplement 3 petites lignes */
return 0;
}