Add CPU stats for greentea tests

pull/7294/head
jeromecoutant 2018-06-21 13:36:50 +02:00
parent 443e37b00c
commit 35c9ddc356
1 changed files with 20 additions and 0 deletions

View File

@ -39,6 +39,10 @@ static char buf[128];
static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
#endif
#if defined(MBED_CPU_STATS_ENABLED)
static void send_CPU_info(void);
#endif
static void send_heap_info(void);
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
static void send_stack_info(void);
@ -65,8 +69,24 @@ void greentea_metrics_report()
send_stack_info();
Thread::attach_terminate_hook(NULL);
#endif
#if defined(MBED_CPU_STATS_ENABLED)
send_CPU_info();
#endif
}
#if defined(MBED_CPU_STATS_ENABLED)
static void send_CPU_info()
{
mbed_stats_cpu_t stats;
mbed_stats_cpu_get(&stats);
greentea_send_kv("__cpu_info up time", stats.uptime);
greentea_send_kv("__cpu_info sleep time", stats.sleep_time);
greentea_send_kv("__cpu_info deepsleep time", stats.deep_sleep_time);
greentea_send_kv("__cpu_info % sleep/deep", (stats.sleep_time * 100) / stats.uptime, (stats.deep_sleep_time * 100) / stats.uptime);
}
#endif
static void send_heap_info()
{
mbed_stats_heap_t heap_stats;