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:
@ -850,7 +850,7 @@ ALLOC_FRAME(WASMExecEnv *exec_env, uint32 size, WASMInterpFrame *prev_frame)
|
||||
if (frame) {
|
||||
frame->prev_frame = prev_frame;
|
||||
#if WASM_ENABLE_PERF_PROFILING != 0
|
||||
frame->time_started = os_time_get_boot_microsecond();
|
||||
frame->time_started = os_time_thread_cputime_us();
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
@ -866,9 +866,14 @@ FREE_FRAME(WASMExecEnv *exec_env, WASMInterpFrame *frame)
|
||||
{
|
||||
#if WASM_ENABLE_PERF_PROFILING != 0
|
||||
if (frame->function) {
|
||||
WASMInterpFrame *prev_frame = frame->prev_frame;
|
||||
frame->function->total_exec_time +=
|
||||
os_time_get_boot_microsecond() - frame->time_started;
|
||||
os_time_thread_cputime_us() - frame->time_started;
|
||||
frame->function->total_exec_cnt++;
|
||||
|
||||
if (prev_frame && prev_frame->function)
|
||||
prev_frame->function->children_exec_time +=
|
||||
frame->function->total_exec_time;
|
||||
}
|
||||
#endif
|
||||
wasm_exec_env_free_wasm_frame(exec_env, frame);
|
||||
|
||||
Reference in New Issue
Block a user