Skip to content

Commit f10bb88

Browse files
author
Cruz Monrreal
authored
Merge pull request #7294 from jeromecoutant/PR_GREENTEA_STAT
Add CPU stats for greentea tests
2 parents 58fa28b + 35c9ddc commit f10bb88

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

features/frameworks/greentea-client/source/greentea_metrics.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ static char buf[128];
3939
static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
4040
#endif
4141

42+
#if defined(MBED_CPU_STATS_ENABLED)
43+
static void send_CPU_info(void);
44+
#endif
45+
4246
static void send_heap_info(void);
4347
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
4448
static void send_stack_info(void);
@@ -65,7 +69,23 @@ void greentea_metrics_report()
6569
send_stack_info();
6670
Thread::attach_terminate_hook(NULL);
6771
#endif
72+
#if defined(MBED_CPU_STATS_ENABLED)
73+
send_CPU_info();
74+
#endif
75+
}
76+
77+
#if defined(MBED_CPU_STATS_ENABLED)
78+
static void send_CPU_info()
79+
{
80+
mbed_stats_cpu_t stats;
81+
mbed_stats_cpu_get(&stats);
82+
83+
greentea_send_kv("__cpu_info up time", stats.uptime);
84+
greentea_send_kv("__cpu_info sleep time", stats.sleep_time);
85+
greentea_send_kv("__cpu_info deepsleep time", stats.deep_sleep_time);
86+
greentea_send_kv("__cpu_info % sleep/deep", (stats.sleep_time * 100) / stats.uptime, (stats.deep_sleep_time * 100) / stats.uptime);
6887
}
88+
#endif
6989

7090
static void send_heap_info()
7191
{

0 commit comments

Comments
 (0)