Created
October 12, 2020 13:28
-
-
Save nclv/bf1518d9255f8c9978e312eefe380949 to your computer and use it in GitHub Desktop.
Module pour effectuer l'analyse temporelle de plusieurs fonctions avec des arguments différents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _CONST_ | |
#define _CONST_ | |
#define n (1000) | |
#define m (1000) | |
#define RANGE (100) | |
typedef double E; | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "timing.h" | |
#include <stdio.h> | |
#include <time.h> | |
void generic_fn_execution_time(t_args_wrapper *args_wrapper, | |
void (*generic_fn)(t_args_wrapper *)) { | |
static clock_t start, end; | |
static double cpu_time_used; | |
start = clock(); | |
(*generic_fn)(args_wrapper); | |
end = clock(); | |
cpu_time_used = ((double)(end - start)) / CLOCKS_PER_SEC; | |
printf("CPU time used: %lf\n", cpu_time_used); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _TIMING_ | |
#define _TIMING_ | |
#include <stdlib.h> | |
#include "const.h" | |
typedef struct mergesort_args { | |
size_t _n; | |
E *array; | |
E *buffer; | |
} t_mergesort_args; | |
typedef struct transposition_args { | |
double **matrix; | |
double **result; | |
} t_transposition_args; | |
typedef struct array2d_min_max_args { | |
double **matrix; | |
double *line; | |
double *col; | |
} t_array2d_min_max_args; | |
// Wrapper | |
typedef struct args_wrapper { | |
t_mergesort_args *mergesort_args; | |
t_transposition_args *transposition_args; | |
t_array2d_min_max_args *array2d_min_max_args; | |
} t_args_wrapper; | |
extern void generic_fn_execution_time(t_args_wrapper *args_wrapper, | |
void (*generic_fn)(t_args_wrapper *)); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Petit exemple d'utilisation