From c38ab04be423b3b096f9d5c6fe4d369f22762f5e Mon Sep 17 00:00:00 2001 From: Armando Luiz Nicolini Delgado <nicolui@inf.ufpr.br> Date: Wed, 10 Nov 2021 10:32:24 -0300 Subject: [PATCH] =?UTF-8?q?*=20Adicionada=20fun=C3=A7=C3=A3o=20'markerName?= =?UTF-8?q?'=20para=20gerar=20nomes=20de=20marcadores=20LIKWID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/alt/utils-01.c | 15 +++++++++++++++ utils/alt/utils-01.h | 6 ++++++ utils/utils.c | 22 ++++++++++++++++++---- utils/utils.h | 8 +++++++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/utils/alt/utils-01.c b/utils/alt/utils-01.c index 69cbaf8..8acfd17 100644 --- a/utils/alt/utils-01.c +++ b/utils/alt/utils-01.c @@ -1,4 +1,6 @@ #include <stdio.h> +#include <string.h> +#include <math.h> #include "utils.h" @@ -18,3 +20,16 @@ double timestamp(void) clock_gettime(CLOCK_MONOTONIC_RAW, &tp); return((double)(tp.tv_sec*1.0e3 + tp.tv_nsec*1.0e-6)); } + +string_t markerName(string_t baseName, int n) +{ + string_t mark = (string_t) malloc( (strlen(baseName)+1) + (log10(n)+1) + 1 ); + + sprintf(mark, "%s_%u", baseName,n); + + // printf("*** %s\n", mark); + + return mark; + +} + diff --git a/utils/alt/utils-01.h b/utils/alt/utils-01.h index 594f595..5c10efd 100644 --- a/utils/alt/utils-01.h +++ b/utils/alt/utils-01.h @@ -4,7 +4,13 @@ #include <stdlib.h> #include <time.h> + +typedef double real_t; +typedef double rtime_t; +typedef char * string_t; + double timestamp(void); +string_t markerName(string_t baseName, int n); #endif // __UTILS_H__ diff --git a/utils/utils.c b/utils/utils.c index e712d67..8acfd17 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -1,4 +1,7 @@ #include <stdio.h> +#include <string.h> +#include <math.h> + #include "utils.h" /* Retorna tempo em milisegundos @@ -13,9 +16,20 @@ double timestamp(void) { - struct timeval tp; - gettimeofday(&tp, NULL); - // printf("\n*** %7.10lf ms %7.10lf ms\n", tp.tv_sec*1.0e3, tp.tv_usec*1.0e-3); - return((double)(tp.tv_sec*1.0e3 + tp.tv_usec*1.0e-3)); + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC_RAW, &tp); + return((double)(tp.tv_sec*1.0e3 + tp.tv_nsec*1.0e-6)); +} + +string_t markerName(string_t baseName, int n) +{ + string_t mark = (string_t) malloc( (strlen(baseName)+1) + (log10(n)+1) + 1 ); + + sprintf(mark, "%s_%u", baseName,n); + + // printf("*** %s\n", mark); + + return mark; + } diff --git a/utils/utils.h b/utils/utils.h index 14a0cce..5c10efd 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -2,9 +2,15 @@ #define __UTILS_H__ #include <stdlib.h> -#include <sys/time.h> +#include <time.h> + + +typedef double real_t; +typedef double rtime_t; +typedef char * string_t; double timestamp(void); +string_t markerName(string_t baseName, int n); #endif // __UTILS_H__ -- GitLab