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:
@ -6,8 +6,15 @@
|
||||
#include "platform_api_vmcore.h"
|
||||
|
||||
uint64
|
||||
os_time_get_boot_microsecond()
|
||||
os_time_get_boot_us()
|
||||
{
|
||||
TickType_t ticks = xTaskGetTickCount();
|
||||
return (uint64)1000 * 1000 / configTICK_RATE_HZ * ticks;
|
||||
}
|
||||
|
||||
uint64
|
||||
os_time_thread_cputime_us(void)
|
||||
{
|
||||
/* FIXME if u know the right api */
|
||||
return os_time_get_boot_us();
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
#include "platform_api_vmcore.h"
|
||||
|
||||
uint64
|
||||
os_time_get_boot_microsecond()
|
||||
os_time_get_boot_us()
|
||||
{
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
|
||||
@ -15,3 +15,14 @@ os_time_get_boot_microsecond()
|
||||
|
||||
return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
|
||||
}
|
||||
|
||||
uint64
|
||||
os_time_thread_cputime_us()
|
||||
{
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000;
|
||||
}
|
||||
Reference in New Issue
Block a user