1 /* memmap_b.c */
2 
3 /*
4  * Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include "master.h"
10 #include <zephyr/kernel.h>
11 
12 /**
13  * @brief Memory map get/free test
14  */
memorymap_test(void)15 void memorymap_test(void)
16 {
17 	uint32_t et; /* elapsed time */
18 	timing_t  start;
19 	timing_t  end;
20 	int i;
21 	void *p;
22 	int alloc_status;
23 
24 	PRINT_STRING(dashline);
25 	start = timing_timestamp_get();
26 	for (i = 0; i < NR_OF_MAP_RUNS; i++) {
27 		alloc_status = k_mem_slab_alloc(&MAP1, &p, K_FOREVER);
28 		if (alloc_status != 0) {
29 			PRINT_F(FORMAT,
30 				"Error: Slab allocation failed.", alloc_status);
31 			break;
32 		}
33 		k_mem_slab_free(&MAP1, p);
34 	}
35 	end = timing_timestamp_get();
36 	et = (uint32_t)timing_cycles_get(&start, &end);
37 
38 	PRINT_F(FORMAT, "average alloc and dealloc memory page",
39 		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS)));
40 }
41