sw_perf/profiling.c

44 lines
1.5 KiB
C

/*********************************************************************************************
Description: data for profiling
Copyright : All right reserved by NCIC.ICT
Author : Zhang Zhonghai
Date : 2024/04/08
***********************************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
#include <time.h>
#include <sys/time.h>
#include "profiling.h"
uint64_t gprof[LIM_TYPE] = {0};
uint64_t gdata[LIM_TYPE] = {0};
FILE *ins_f_arr[LIM_TYPE],
*del_f_arr[LIM_TYPE],
*score_f_arr[LIM_TYPE],
*retval_f_arr[LIM_TYPE];
/* for profiling time */
uint64_t get_msec()
{
// struct timeval tv;
// gettimeofday(&tv, NULL);
// return (uint64_t)1000 * (tv.tv_sec + ((1e-6) * tv.tv_usec));
return clock();
}
/* show excution time */
int display_extend_stats()
{
#ifdef SHOW_PERF
fprintf(stderr, "[extend scalar ] time: %9.6lf s; score: %ld\n", gprof[G_EXT_SCALAR] / TIME_DIVIDE_BY, gdata[G_EXT_SCALAR]);
fprintf(stderr, "[extend avx i16] time: %9.6lf s; score: %ld\n", gprof[G_EXT_AVX2_I16] / TIME_DIVIDE_BY, gdata[G_EXT_AVX2_I16]);
fprintf(stderr, "[extend avx u8 ] time: %9.6lf s; score: %ld\n", gprof[G_EXT_AVX2_U8] / TIME_DIVIDE_BY, gdata[G_EXT_AVX2_U8]);
fprintf(stderr, "[extend avx sp ] time: %9.6lf s; score: %ld\n", gprof[G_EXT_AVX2_I16_SP] / TIME_DIVIDE_BY, gdata[G_EXT_AVX2_I16_SP]);
#endif
return 0;
}