Enhancements on wasm function execution time statistic (#2985)
Enhance the statistic of wasm function execution time, or the performance profiling feature: - Add os_time_thread_cputime_us() to get the cputime of a thread, and use it to calculate the execution time of a wasm function - Support the statistic of the children execution time of a function, and dump it in wasm_runtime_dump_perf_profiling - Expose two APIs: wasm_runtime_sum_wasm_exec_time wasm_runtime_get_wasm_func_exec_time And rename os_time_get_boot_microsecond to os_time_get_boot_us.
This commit is contained in:
@ -927,7 +927,7 @@ clock_gettime_wrapper(wasm_exec_env_t exec_env, uint32 clk_id,
|
||||
if (!validate_native_addr(ts_app, sizeof(struct timespec_app)))
|
||||
return (uint32)-1;
|
||||
|
||||
time = os_time_get_boot_microsecond();
|
||||
time = os_time_get_boot_us();
|
||||
ts_app->tv_sec = time / 1000000;
|
||||
ts_app->tv_nsec = (time % 1000000) * 1000;
|
||||
|
||||
@ -939,7 +939,7 @@ clock_wrapper(wasm_exec_env_t exec_env)
|
||||
{
|
||||
/* Convert to nano seconds as CLOCKS_PER_SEC in wasi-sdk */
|
||||
|
||||
return os_time_get_boot_microsecond() * 1000;
|
||||
return os_time_get_boot_us() * 1000;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_SPEC_TEST != 0
|
||||
|
||||
@ -667,6 +667,12 @@ thread_manager_start_routine(void *arg)
|
||||
since we will exit soon */
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_PERF_PROFILING != 0
|
||||
os_printf("============= Spawned thread ===========\n");
|
||||
wasm_runtime_dump_perf_profiling(module_inst);
|
||||
os_printf("========================================\n");
|
||||
#endif
|
||||
|
||||
/* Free aux stack space */
|
||||
free_aux_stack(exec_env, exec_env->aux_stack_bottom.bottom);
|
||||
/* Remove exec_env */
|
||||
|
||||
Reference in New Issue
Block a user