FastBQSR/src/util/profiling.h

87 lines
2.1 KiB
C
Raw Normal View History

2025-11-23 23:03:37 +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_START(tmp_time) uint64_t prof_tmp_##tmp_time = RealtimeMsec()
#define PROF_START_AGAIN(tmp_time) prof_tmp_##tmp_time = RealtimeMsec()
#define PROF_END(result, tmp_time) result += RealtimeMsec() - prof_tmp_##tmp_time
2026-01-01 00:41:55 +08:00
#define PROF_GP_END(tmp_time) gprof[tmp_time] += RealtimeMsec() - prof_tmp_##tmp_time
#define PROF_TP_END(tmp_time) tprof[tmp_time][thid] += RealtimeMsec() - prof_tmp_##tmp_time
2025-11-23 23:03:37 +08:00
#define PROF_PRINT_START(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_START(tmp_time)
#define PROF_END(result, tmp_time)
#define PROF_GP_END(tmp_time)
2026-01-01 00:41:55 +08:00
#define PROF_TP_END(tmp_time)
2025-11-23 23:03:37 +08:00
#define PROF_PRINT_START(tmp_time)
#define PROF_PRINT_END(tmp_time)
#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 {
2026-01-01 00:41:55 +08:00
GP_clip_read = 11,
GP_calc_snp,
GP_covariate,
GP_read_ref,
GP_read_vcf,
GP_frac_err,
GP_update_info,
2026-01-01 00:41:55 +08:00
GP_merge_covs,
GP_collapse_round,
GP_quantize,
GP_print_report,
2025-11-23 23:03:37 +08:00
GP_read,
GP_write,
2026-01-01 00:41:55 +08:00
GP_thread_worker,
2025-11-23 23:03:37 +08:00
GP_whole_process
};
// 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 };
2026-01-01 00:41:55 +08:00
enum {
TP_clip_read = 11,
TP_calc_snp,
TP_covariate,
TP_read_ref,
TP_read_vcf,
TP_calc_skips,
TP_frac_err,
TP_readgroup,
TP_qualityscore,
TP_context,
TP_cycle,
TP_update_info,
TP_whole_process
};
2025-11-23 23:03:37 +08:00
uint64_t RealtimeMsec(void);
int DisplayProfilingBQSR(int);
int DisplayProfilingApplyBQSR(int);
2025-11-23 23:03:37 +08:00
#ifdef __cplusplus
}
#endif