2025-04-17 16:17:44 +08:00
|
|
|
#pragma once
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
|
|
// #define SHOW_PERF
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define LIM_THREAD 128
|
|
|
|
|
#define LIM_THREAD_PROF_TYPE 128
|
|
|
|
|
#define LIM_GLOBAL_PROF_TYPE 128
|
|
|
|
|
#define LIM_THREAD_DATA_TYPE 128
|
|
|
|
|
#define LIM_GLOBAL_DATA_TYPE 128
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_PERF
|
|
|
|
|
extern uint64_t proc_freq;
|
|
|
|
|
extern uint64_t tprof[LIM_THREAD_PROF_TYPE][LIM_THREAD];
|
|
|
|
|
extern uint64_t gprof[LIM_GLOBAL_PROF_TYPE];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_PERF
|
|
|
|
|
#define PROF_G_BEG(time_name) uint64_t prof_G_tmp_##time_name = realtimeMsec()
|
|
|
|
|
#define PROF_G_BEG_AGAIN(time_name) prof_G_tmp_##time_name = realtimeMsec()
|
|
|
|
|
#define PROF_G_END(time_name) gprof[GP_##time_name] += realtimeMsec() - prof_G_tmp_##time_name
|
|
|
|
|
#define PROF_T_BEG(time_name) uint64_t prof_T_tmp_##time_name = realtimeMsec()
|
|
|
|
|
#define PROF_T_BEG_AGAIN(time_name) prof_T_tmp_##time_name = realtimeMsec()
|
|
|
|
|
#define PROF_T_END(tid, time_name) tprof[TP_##time_name][tid] += realtimeMsec() - prof_T_tmp_##time_name
|
|
|
|
|
#define PROF_PRINT_BEG(tmp_time) uint64_t tmp_time = realtimeMsec()
|
|
|
|
|
#define PROF_PRINT_END(tmp_time) \
|
|
|
|
|
tmp_time = realtimeMsec() - tmp_time; \
|
|
|
|
|
fprintf(stderr, "time %-15s: %0.2lfs\n", #tmp_time, tmp_time * 1.0 / proc_freq)
|
|
|
|
|
#else
|
|
|
|
|
#define PROF_G_BEG(time_name)
|
|
|
|
|
#define PROF_G_BEG_AGAIN(time_name)
|
|
|
|
|
#define PROF_G_END(time_name)
|
|
|
|
|
#define PROF_T_BEG(time_name)
|
|
|
|
|
#define PROF_T_BEG_AGAIN(time_name)
|
|
|
|
|
#define PROF_T_END(tid, time_name)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GLOBAL
|
|
|
|
|
enum { GP_0 = 0, GP_1, GP_2, GP_3, GP_4, GP_5, GP_6, GP_7, GP_8, GP_9, GP_10 };
|
|
|
|
|
enum {
|
|
|
|
|
GP_mid_all = 11,
|
|
|
|
|
GP_read,
|
|
|
|
|
GP_mem_copy,
|
|
|
|
|
GP_parse_block,
|
|
|
|
|
GP_uncompress,
|
|
|
|
|
GP_sort,
|
2025-12-16 23:44:49 +08:00
|
|
|
GP_merge,
|
|
|
|
|
GP_compress,
|
2025-04-17 16:17:44 +08:00
|
|
|
GP_write_mid,
|
|
|
|
|
GP_read_mid,
|
|
|
|
|
GP_write_final
|
|
|
|
|
};
|
|
|
|
|
// THREAD
|
|
|
|
|
enum { TP_0 = 0, TP_1, TP_2, TP_3, TP_4, TP_5, TP_6, TP_7, TP_8, TP_9, TP_10 };
|
|
|
|
|
enum { TP_sort = 11, TP_mem_copy};
|
|
|
|
|
|
|
|
|
|
uint64_t realtimeMsec(void);
|
|
|
|
|
|
|
|
|
|
int displayProfiling(int);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|