benchmarks: boot_time: Move to unified kernel
Right now works only on x86, filed bug to address all architectures (ZEP-1414). Change-Id: Iba53b3688b2b78a4189df0b50578070a8d2ac8b2 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
01652bd876
commit
58ccb64a74
6 changed files with 169 additions and 0 deletions
4
tests/benchmarks/boot_time/Makefile
Normal file
4
tests/benchmarks/boot_time/Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
BOARD ?= qemu_x86
|
||||
CONF_FILE = prj.conf
|
||||
|
||||
include ${ZEPHYR_BASE}/Makefile.inc
|
64
tests/benchmarks/boot_time/README.txt
Normal file
64
tests/benchmarks/boot_time/README.txt
Normal file
|
@ -0,0 +1,64 @@
|
|||
Title: Boot Time Measurement
|
||||
|
||||
Description:
|
||||
|
||||
BootTime measures the time:
|
||||
a) from system reset to kernel start (crt0.s's __start)
|
||||
b) from kernel start to begin of main()
|
||||
c) from kernel start to begin of first task
|
||||
d) from kernel start to when microkernel's main task goes immediately idle
|
||||
|
||||
The project can be built using one of the following three configurations:
|
||||
|
||||
best
|
||||
-------
|
||||
- Disables most features
|
||||
- Provides best case boot measurement
|
||||
|
||||
default
|
||||
-------
|
||||
- Default configuration options
|
||||
- Provides typical boot measurement
|
||||
|
||||
worst
|
||||
-------
|
||||
- Enables most features.
|
||||
- Provides worst case boot measurement
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Building and Running Project:
|
||||
|
||||
This benchmark outputs to the console. It can be built and executed
|
||||
on QEMU as follows:
|
||||
|
||||
make qemu
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Troubleshooting:
|
||||
|
||||
Problems caused by out-dated project information can be addressed by
|
||||
issuing one of the following commands then rebuilding the project:
|
||||
|
||||
make clean # discard results of previous builds
|
||||
# but keep existing configuration info
|
||||
or
|
||||
make pristine # discard results of previous builds
|
||||
# and restore pre-defined configuration info
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Sample Output:
|
||||
|
||||
tc_start() - Boot Time Measurement
|
||||
MicroKernel Boot Result: Clock Frequency: 20 MHz
|
||||
__start : 377787 cycles, 18889 us
|
||||
_start->main(): 3915 cycles, 195 us
|
||||
_start->task : 5898 cycles, 294 us
|
||||
_start->idle : 6399 cycles, 319 us
|
||||
Boot Time Measurement finished
|
||||
===================================================================
|
||||
PASS - bootTimeTask.
|
||||
===================================================================
|
||||
PROJECT EXECUTION SUCCESSFUL
|
3
tests/benchmarks/boot_time/prj.conf
Normal file
3
tests/benchmarks/boot_time/prj.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
CONFIG_PERFORMANCE_METRICS=y
|
||||
CONFIG_BOOT_TIME_MEASUREMENT=y
|
||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
4
tests/benchmarks/boot_time/src/Makefile
Normal file
4
tests/benchmarks/boot_time/src/Makefile
Normal file
|
@ -0,0 +1,4 @@
|
|||
ccflags-y += -I$(CURDIR)/misc/generated/sysgen
|
||||
ccflags-y += -I$(ZEPHYR_BASE)/tests/include
|
||||
|
||||
obj-y = main.o
|
90
tests/benchmarks/boot_time/src/main.c
Normal file
90
tests/benchmarks/boot_time/src/main.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2015 Wind River Systems, Inc.
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Measure boot time
|
||||
*
|
||||
* Measuring the boot time
|
||||
* 1. From reset to kernel's __start
|
||||
* 2. From __start to main()
|
||||
* 3. From __start to task
|
||||
* 4. From __start to idle
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <tc_util.h>
|
||||
|
||||
/* externs */
|
||||
extern uint64_t __start_tsc; /* timestamp when kernel begins executing */
|
||||
extern uint64_t __main_tsc; /* timestamp when main() begins executing */
|
||||
extern uint64_t __idle_tsc; /* timestamp when CPU went idle */
|
||||
|
||||
void main(void)
|
||||
{
|
||||
uint64_t task_tsc; /* timestamp at beginning of first task */
|
||||
uint64_t _start_us; /* being of __start timestamp in us */
|
||||
uint64_t main_us; /* begin of main timestamp in us */
|
||||
uint64_t task_us; /* begin of task timestamp in us */
|
||||
uint64_t s_main_tsc; /* __start->main timestamp */
|
||||
uint64_t s_task_tsc; /*__start->task timestamp */
|
||||
uint64_t idle_us; /* begin of idle timestamp in us */
|
||||
uint64_t s_idle_tsc; /*__start->idle timestamp */
|
||||
|
||||
task_tsc = _tsc_read();
|
||||
|
||||
/*
|
||||
* Go to sleep for 1 tick in order to timestamp when idle thread halts.
|
||||
*/
|
||||
k_sleep(1);
|
||||
|
||||
int freq = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 1000000;
|
||||
|
||||
_start_us = __start_tsc / freq;
|
||||
s_main_tsc = __main_tsc - __start_tsc;
|
||||
main_us = s_main_tsc / freq;
|
||||
s_task_tsc = task_tsc - __start_tsc;
|
||||
task_us = s_task_tsc / freq;
|
||||
s_idle_tsc = __idle_tsc - __start_tsc;
|
||||
idle_us = s_idle_tsc / freq;
|
||||
|
||||
/* Indicate start for sanity test suite */
|
||||
TC_START("Boot Time Measurement");
|
||||
|
||||
/* Only print lower 32bit of time result */
|
||||
TC_PRINT("Boot Result: Clock Frequency: %d MHz\n",
|
||||
freq);
|
||||
TC_PRINT("__start : %d cycles, %d us\n",
|
||||
(uint32_t)(__start_tsc & 0xFFFFFFFFULL),
|
||||
(uint32_t) (_start_us & 0xFFFFFFFFULL));
|
||||
TC_PRINT("_start->main(): %d cycles, %d us\n",
|
||||
(uint32_t)(s_main_tsc & 0xFFFFFFFFULL),
|
||||
(uint32_t) (main_us & 0xFFFFFFFFULL));
|
||||
TC_PRINT("_start->task : %d cycles, %d us\n",
|
||||
(uint32_t)(s_task_tsc & 0xFFFFFFFFULL),
|
||||
(uint32_t) (task_us & 0xFFFFFFFFULL));
|
||||
TC_PRINT("_start->idle : %d cycles, %d us\n",
|
||||
(uint32_t)(s_idle_tsc & 0xFFFFFFFFULL),
|
||||
(uint32_t) (idle_us & 0xFFFFFFFFULL));
|
||||
|
||||
TC_PRINT("Boot Time Measurement finished\n");
|
||||
|
||||
/* for sanity regression test utility. */
|
||||
TC_END_RESULT(TC_PASS);
|
||||
TC_END_REPORT(TC_PASS);
|
||||
|
||||
}
|
4
tests/benchmarks/boot_time/testcase.ini
Normal file
4
tests/benchmarks/boot_time/testcase.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[test]
|
||||
tags = benchmark
|
||||
arch_whitelist = x86
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue