mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: initial include of bench_sizeof_coretypes
This commit is contained in:
parent
104de7b621
commit
a61b5e3605
17
tests/bench_sizeof_coretypes/Makefile
Normal file
17
tests/bench_sizeof_coretypes/Makefile
Normal file
@ -0,0 +1,17 @@
|
||||
include ../Makefile.tests_common
|
||||
|
||||
# Modules that will have an impact on the size of the TCB (thread_t):
|
||||
#
|
||||
# disabled by default, enable on demand:
|
||||
ifneq (,$(USE_FLAGS))
|
||||
USEMODULE += core_thread_flags
|
||||
endif
|
||||
#
|
||||
# enabled by default, disable on demand:
|
||||
ifneq (,$(NO_MSG))
|
||||
DISABLE_MODULE += core_msg
|
||||
endif
|
||||
|
||||
TEST_ON_CI_WHITELIST += all
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
6
tests/bench_sizeof_coretypes/README.md
Normal file
6
tests/bench_sizeof_coretypes/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Measure Size of Core Types
|
||||
|
||||
This application simply list the size of all significant types defined by the
|
||||
RIOT core. Its purpose is to provide a base for tracking the memory requirements
|
||||
of those types over time and to provide a simple way to judge the impacts of
|
||||
future core changes on memory usage.
|
112
tests/bench_sizeof_coretypes/main.c
Normal file
112
tests/bench_sizeof_coretypes/main.c
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
|
||||
* 2018 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup tests
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Print size of core types
|
||||
*
|
||||
* @author René Kijewski <rene.kijewski@fu-berlin.de>
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "cib.h"
|
||||
#include "clist.h"
|
||||
#include "panic.h"
|
||||
#include "kernel_types.h"
|
||||
#include "list.h"
|
||||
#include "mbox.h"
|
||||
#include "msg.h"
|
||||
#include "mutex.h"
|
||||
#include "priority_queue.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "rmutex.h"
|
||||
#ifdef MODULE_CORE_THREAD_FLAGS
|
||||
#include "thread_flags.h"
|
||||
#endif
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
#define P(NAME) printf(" tcb->%-11s %3u %3u\n", #NAME, \
|
||||
(unsigned)sizeof(((thread_t *) 0)->NAME), \
|
||||
(unsigned)offsetof(thread_t, NAME))
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("Sizeof RIOT core types\n");
|
||||
|
||||
puts(" size");
|
||||
|
||||
printf("sizeof(cib_t): %3u\n",
|
||||
(unsigned)sizeof(cib_t));
|
||||
printf("sizeof(clist_node_t): %3u\n",
|
||||
(unsigned)sizeof(clist_node_t));
|
||||
printf("sizeof(core_panic_t): %3u\n",
|
||||
(unsigned)sizeof(core_panic_t));
|
||||
printf("sizeof(kernel_pid_t): %3u\n",
|
||||
(unsigned)sizeof(kernel_pid_t));
|
||||
printf("sizeof(list_node_t): %3u\n",
|
||||
(unsigned)sizeof(list_node_t));
|
||||
printf("sizeof(mbox_t): %3u\n",
|
||||
(unsigned)sizeof(mbox_t));
|
||||
#ifdef MODULE_CORE_MSG
|
||||
printf("sizeof(msg_t): %3u\n",
|
||||
(unsigned)sizeof(msg_t));
|
||||
#else
|
||||
puts("sizeof(msg_t): 0 (not enabled)");
|
||||
#endif
|
||||
printf("sizeof(mutex_t): %3u\n",
|
||||
(unsigned)sizeof(mutex_t));
|
||||
printf("sizeof(priority_queue_node_t): %3u\n",
|
||||
(unsigned)sizeof(priority_queue_node_t));
|
||||
printf("sizeof(priority_queue_t): %3u\n",
|
||||
(unsigned)sizeof(priority_queue_t));
|
||||
printf("sizeof(ringbuffer_t): %3u\n",
|
||||
(unsigned)sizeof(ringbuffer_t));
|
||||
printf("sizeof(rmutex_t): %3u\n",
|
||||
(unsigned)sizeof(rmutex_t));
|
||||
#ifdef MODULE_CORE_THREAD_FLAGS
|
||||
printf("sizeof(thread_flags_t): %3u\n",
|
||||
(unsigned)sizeof(thread_flags_t));
|
||||
#else
|
||||
puts("sizeof(thread_flags_t): 0 (not enabled)");
|
||||
#endif
|
||||
printf("\nTCB (thread_t) details: size offset\n");
|
||||
printf("sizeof(thread_t): %3u -\n",
|
||||
(unsigned)sizeof(thread_t));
|
||||
P(sp);
|
||||
P(status);
|
||||
P(priority);
|
||||
P(pid);
|
||||
#ifdef MODULE_CORE_THREAD_FLAGS
|
||||
P(flags);
|
||||
#endif
|
||||
P(rq_entry);
|
||||
#ifdef MODULE_CORE_MSG
|
||||
P(wait_data);
|
||||
P(msg_waiters);
|
||||
P(msg_queue);
|
||||
P(msg_array);
|
||||
#endif
|
||||
#ifdef DEVELHELP
|
||||
P(name);
|
||||
#endif
|
||||
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) || defined(MODULE_MPU_STACK_GUARD)
|
||||
P(stack_start);
|
||||
#endif
|
||||
|
||||
puts("\n[SUCCESS]");
|
||||
return 0;
|
||||
}
|
20
tests/bench_sizeof_coretypes/tests/01-run.py
Executable file
20
tests/bench_sizeof_coretypes/tests/01-run.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (C) 2018 Freie Universität Berlin
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU Lesser
|
||||
# General Public License v2.1. See the file LICENSE in the top level
|
||||
# directory for more details.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def testfunc(child):
|
||||
child.expect_exact('[SUCCESS]')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.path.append(os.path.join(os.environ['RIOTTOOLS'], 'testrunner'))
|
||||
from testrunner import run
|
||||
sys.exit(run(testfunc))
|
Loading…
Reference in New Issue
Block a user