David Brown | f6d14c2 | 2019-12-10 15:36:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 Linaro Limited |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef H_ZEPHYR_BENCH_H__ |
| 18 | #define H_ZEPHYR_BENCH_H__ |
| 19 | |
| 20 | #include <inttypes.h> |
| 21 | #include <stdint.h> |
| 22 | #include "zephyr.h" |
| 23 | #include "bootutil/bootutil_log.h" |
| 24 | |
| 25 | /* TODO: Unclear if this can be here (redundantly). */ |
| 26 | MCUBOOT_LOG_MODULE_DECLARE(mcuboot); |
| 27 | |
| 28 | typedef uint32_t bench_state_t; |
| 29 | |
| 30 | #define plat_bench_start(_s) do { \ |
| 31 | BOOT_LOG_ERR("start benchmark"); \ |
| 32 | *(_s) = k_cycle_get_32(); \ |
| 33 | } while (0) |
| 34 | |
| 35 | #define plat_bench_stop(_s) do { \ |
| 36 | uint32_t _stop_time = k_cycle_get_32(); \ |
| 37 | BOOT_LOG_ERR("bench: %" PRId32 " cycles", _stop_time - *(_s)); \ |
| 38 | } while (0) |
| 39 | |
| 40 | #endif /* not H_ZEPHYR_BENCH_H__ */ |