diff options
author | Anas Nashif <anas.nashif@intel.com> | 2016-11-05 14:34:40 -0400 |
---|---|---|
committer | Anas Nashif <nashif@linux.intel.com> | 2017-01-31 19:26:04 +0000 |
commit | 58ccb64a74a7f11169c7e7f0d2884f6936f975bf (patch) | |
tree | 3625c8fc60b6c6cd1b116ba57a750ccada270291 | |
parent | 01652bd876a0941376a5e11be8b36d156cf42e93 (diff) |
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>
-rw-r--r-- | tests/benchmarks/boot_time/Makefile | 4 | ||||
-rw-r--r-- | tests/benchmarks/boot_time/README.txt | 64 | ||||
-rw-r--r-- | tests/benchmarks/boot_time/prj.conf | 3 | ||||
-rw-r--r-- | tests/benchmarks/boot_time/src/Makefile | 4 | ||||
-rw-r--r-- | tests/benchmarks/boot_time/src/main.c | 90 | ||||
-rw-r--r-- | tests/benchmarks/boot_time/testcase.ini | 4 |
6 files changed, 169 insertions, 0 deletions
diff --git a/tests/benchmarks/boot_time/Makefile b/tests/benchmarks/boot_time/Makefile new file mode 100644 index 000000000..4de50f93d --- /dev/null +++ b/tests/benchmarks/boot_time/Makefile @@ -0,0 +1,4 @@ +BOARD ?= qemu_x86 +CONF_FILE = prj.conf + +include ${ZEPHYR_BASE}/Makefile.inc diff --git a/tests/benchmarks/boot_time/README.txt b/tests/benchmarks/boot_time/README.txt new file mode 100644 index 000000000..606816630 --- /dev/null +++ b/tests/benchmarks/boot_time/README.txt @@ -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 diff --git a/tests/benchmarks/boot_time/prj.conf b/tests/benchmarks/boot_time/prj.conf new file mode 100644 index 000000000..927d9e643 --- /dev/null +++ b/tests/benchmarks/boot_time/prj.conf @@ -0,0 +1,3 @@ +CONFIG_PERFORMANCE_METRICS=y +CONFIG_BOOT_TIME_MEASUREMENT=y +CONFIG_TEST_RANDOM_GENERATOR=y diff --git a/tests/benchmarks/boot_time/src/Makefile b/tests/benchmarks/boot_time/src/Makefile new file mode 100644 index 000000000..bd27c297f --- /dev/null +++ b/tests/benchmarks/boot_time/src/Makefile @@ -0,0 +1,4 @@ +ccflags-y += -I$(CURDIR)/misc/generated/sysgen +ccflags-y += -I$(ZEPHYR_BASE)/tests/include + +obj-y = main.o diff --git a/tests/benchmarks/boot_time/src/main.c b/tests/benchmarks/boot_time/src/main.c new file mode 100644 index 000000000..cb358ca93 --- /dev/null +++ b/tests/benchmarks/boot_time/src/main.c @@ -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); + +} diff --git a/tests/benchmarks/boot_time/testcase.ini b/tests/benchmarks/boot_time/testcase.ini new file mode 100644 index 000000000..3609d3009 --- /dev/null +++ b/tests/benchmarks/boot_time/testcase.ini @@ -0,0 +1,4 @@ +[test] +tags = benchmark +arch_whitelist = x86 + |