perf profiling: Adjust the calculation of execution time (#3089)

This commit is contained in:
liang.he 2024-01-26 18:06:21 +08:00 committed by GitHub
parent 9fb5fcc709
commit 99bbad8cdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 17 deletions

View File

@ -2845,14 +2845,13 @@ aot_free_frame(WASMExecEnv *exec_env)
AOTFrame *prev_frame = cur_frame->prev_frame;
#if WASM_ENABLE_PERF_PROFILING != 0
cur_frame->func_perf_prof_info->total_exec_time +=
os_time_thread_cputime_us() - cur_frame->time_started;
uint64 elapsed = os_time_thread_cputime_us() - cur_frame->time_started;
cur_frame->func_perf_prof_info->total_exec_time += elapsed;
cur_frame->func_perf_prof_info->total_exec_cnt++;
/* parent function */
if (prev_frame)
prev_frame->func_perf_prof_info->children_exec_time =
cur_frame->func_perf_prof_info->total_exec_time;
prev_frame->func_perf_prof_info->children_exec_time += elapsed;
#endif
wasm_exec_env_free_wasm_frame(exec_env, cur_frame);

View File

@ -867,13 +867,12 @@ 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_thread_cputime_us() - frame->time_started;
uint64 elapsed = os_time_thread_cputime_us() - frame->time_started;
frame->function->total_exec_time += elapsed;
frame->function->total_exec_cnt++;
if (prev_frame && prev_frame->function)
prev_frame->function->children_exec_time +=
frame->function->total_exec_time;
prev_frame->function->children_exec_time += elapsed;
}
#endif
wasm_exec_env_free_wasm_frame(exec_env, frame);

View File

@ -901,14 +901,12 @@ 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_thread_cputime_us() - frame->time_started;
uint64 elapsed = os_time_thread_cputime_us() - frame->time_started;
frame->function->total_exec_time += elapsed;
frame->function->total_exec_cnt++;
if (prev_frame && prev_frame->function)
prev_frame->function->children_exec_time +=
frame->function->total_exec_time;
prev_frame->function->children_exec_time += elapsed;
}
#endif
wasm_exec_env_free_wasm_frame(exec_env, frame);

View File

@ -3455,14 +3455,13 @@ llvm_jit_free_frame(WASMExecEnv *exec_env)
#if WASM_ENABLE_PERF_PROFILING != 0
if (frame->function) {
frame->function->total_exec_time +=
os_time_thread_cputime_us() - frame->time_started;
uint64 elapsed = os_time_thread_cputime_us() - frame->time_started;
frame->function->total_exec_time += elapsed;
frame->function->total_exec_cnt++;
/* parent function */
if (prev_frame)
prev_frame->function->children_exec_time =
frame->function->total_exec_time;
prev_frame->function->children_exec_time += elapsed;
}
#endif
wasm_exec_env_free_wasm_frame(exec_env, frame);