Go to the documentation of this file.
40 #ifdef CHECKASM_PERF_ASM
41 static uint64_t perf_start_asm(
void)
46 static uint64_t perf_stop_asm(uint64_t t)
63 fprintf(stderr,
"checkasm: timers are not available on this system\n");
67 #if defined(CHECKASM_PERF_ASM) && CHECKASM_HAVE_LONGJMP
80 fprintf(stderr,
"checkasm: unable to access %s cycle counter\n",
85 #ifdef CHECKASM_PERF_ASM_INIT
89 CHECKASM_PERF_ASM_INIT();
115 #if ARCH_ARM || ARCH_AARCH64
132 const uint64_t target_nsec = 20000;
133 const uint64_t start_cycles = perf->
start();
140 while (perf->
start() == start_cycles) {
142 fprintf(stderr,
"checkasm: %s timer doesn't increment\n", perf->
name);
154 const uint64_t target_nsec = 20000;
161 for (
int i = 0;
i < 100;
i++)
168 fprintf(stderr,
"checkasm: %s timer doesn't increment\n", perf->
name);
183 void *
const ptr0 = (
void *) 0x1000, *
const ptr1 = (
void *) 0x2000;
188 for (uint64_t total_cycles = 0; total_cycles <
target_cycles;) {
193 for (
int i = 0;
i < 100;
i++)
212 if (!strcmp(perf.
unit,
"nsec")) {
215 .nb_measurements = 1,
222 const uint64_t target_nsec = 100000;
233 for (
int i = 0;
i < 100;
i++)
238 for (
int i = 0;
i < iters;
i++)
244 for (
int i = 0;
i < iters;
i++)
248 assert(
cycles <= INT_MAX);
251 if (nsec > target_nsec)
#define CHECKASM_PERF_ASM_UNIT
CheckasmSample samples[CHECKASM_STATS_SAMPLES]
checkasm_jmp_buf checkasm_context
uint64_t(* start)(void)
Start timing measurement.
COLD int checkasm_perf_init(void)
uint64_t checkasm_gettime_nsec(void)
#define checkasm_save_context(ctx)
uint64_t checkasm_gettime_nsec_diff(uint64_t t)
int checkasm_run_on_all_cores(void(*func)(void))
uint64_t(* stop)(uint64_t start_time)
Stop timing measurement.
const char * name
Name of the timing mechanism (e.g., "clock_gettime")
int checkasm_perf_init_linux(CheckasmPerf *perf)
CHECKASM_API void checkasm_set_signal_handler_state(int enabled)
Enable or disable signal handling.
COLD void checkasm_measure_perf_scale(CheckasmMeasurement *meas)
void checkasm_noop(void *)
CheckasmPerf checkasm_perf
static CheckasmVar checkasm_var_const(double x)
#define CHECKASM_PERF_BENCH(count, time,...)
int checkasm_perf_init_arm(CheckasmPerf *perf)
#define i(width, name, range_min, range_max)
Test writing API for checkasm.
COLD void checkasm_measure_nop_cycles(CheckasmMeasurement *meas, uint64_t target_cycles)
static CheckasmStats stats
static void checkasm_stats_count_grow(CheckasmStats *const stats, uint64_t cycles, uint64_t target_cycles)
const char * unit
Unit of measurement (e.g., "ns", "cycles")
#define CHECKASM_PERF_ASM_NAME
const CheckasmPerf * checkasm_get_perf(void)
static void checkasm_stats_reset(CheckasmStats *const stats)
static void checkasm_measurement_update(CheckasmMeasurement *measurement, const CheckasmStats stats)
COLD int checkasm_perf_validate_start_stop(const CheckasmPerf *perf)
int checkasm_perf_init_macos(CheckasmPerf *perf)
#define CHECKASM_PERF_ASM()
COLD int checkasm_perf_validate_start(const CheckasmPerf *perf)
static void checkasm_stats_add(CheckasmStats *const stats, const CheckasmSample s)