Skip to content

Commit

Permalink
Merge pull request #7294 from jeromecoutant/PR_GREENTEA_STAT
Browse files Browse the repository at this point in the history
Add CPU stats for greentea tests
  • Loading branch information
Cruz Monrreal committed Jun 30, 2018
2 parents 58fa28b + 35c9ddc commit f10bb88
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions features/frameworks/greentea-client/source/greentea_metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -65,7 +69,23 @@ 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()
{
Expand Down

0 comments on commit f10bb88

Please sign in to comment.