Skip to content

Add CPU stats for greentea tests #7294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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