Program to benchmark the speed of the different file system options versus placing data directly into arrays.
Dependencies: DMBasicGUI DMSupport
This program is used to measure the performance of the different file system options on the LPC4088 Display Module.
The performance wiki page and more specifically the software part describes this program and the output.
As the program doesn't use the display at all it can be used on both the 4.3" and 5" display modules.
main.cpp@3:1716747cba16, 2015-03-16 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Mar 16 11:00:15 2015 +0100
- Revision:
- 3:1716747cba16
- Parent:
- 2:ddc1aa3bea3d
- Child:
- 5:788710a95951
- Added support for image decoding benchmarks
- Removed old read/write benchmark files and used images instead
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alindvall | 0:b77503796c51 | 1 | /* |
alindvall | 0:b77503796c51 | 2 | * Copyright 2015 Embedded Artists AB |
alindvall | 0:b77503796c51 | 3 | * |
alindvall | 0:b77503796c51 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
alindvall | 0:b77503796c51 | 5 | * you may not use this file except in compliance with the License. |
alindvall | 0:b77503796c51 | 6 | * You may obtain a copy of the License at |
alindvall | 0:b77503796c51 | 7 | * |
alindvall | 0:b77503796c51 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
alindvall | 0:b77503796c51 | 9 | * |
alindvall | 0:b77503796c51 | 10 | * Unless required by applicable law or agreed to in writing, software |
alindvall | 0:b77503796c51 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
alindvall | 0:b77503796c51 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
alindvall | 0:b77503796c51 | 13 | * See the License for the specific language governing permissions and |
alindvall | 0:b77503796c51 | 14 | * limitations under the License. |
alindvall | 0:b77503796c51 | 15 | */ |
alindvall | 0:b77503796c51 | 16 | |
alindvall | 0:b77503796c51 | 17 | #include "mbed.h" |
alindvall | 0:b77503796c51 | 18 | #include "DMBoard.h" |
alindvall | 0:b77503796c51 | 19 | #include "MCIFileSystem.h" |
alindvall | 0:b77503796c51 | 20 | #include "QSPIFileSystem.h" |
alindvall | 0:b77503796c51 | 21 | #include "USBHostMSD.h" |
embeddedartists | 3:1716747cba16 | 22 | #include "img_data.h" |
embeddedartists | 3:1716747cba16 | 23 | #include "Image.h" |
alindvall | 0:b77503796c51 | 24 | |
alindvall | 0:b77503796c51 | 25 | /****************************************************************************** |
alindvall | 0:b77503796c51 | 26 | * Defines and typedefs |
alindvall | 0:b77503796c51 | 27 | *****************************************************************************/ |
alindvall | 0:b77503796c51 | 28 | |
alindvall | 0:b77503796c51 | 29 | typedef struct { |
embeddedartists | 3:1716747cba16 | 30 | bool rw; // use in the read/write test? Used in image tests regardless |
alindvall | 0:b77503796c51 | 31 | uint32_t size; |
alindvall | 0:b77503796c51 | 32 | const char* fname; |
alindvall | 0:b77503796c51 | 33 | const uint8_t* iflash_direct; |
alindvall | 0:b77503796c51 | 34 | const uint8_t* qspi_direct; |
alindvall | 0:b77503796c51 | 35 | } bench_input_t; |
alindvall | 0:b77503796c51 | 36 | |
alindvall | 0:b77503796c51 | 37 | #define NUM_BENCHMARKS (sizeof(BENCHMARK_INPUT)/sizeof(BENCHMARK_INPUT[0])) |
alindvall | 0:b77503796c51 | 38 | |
alindvall | 0:b77503796c51 | 39 | #define COPYBUF_SIZE (10*1024*1024) |
alindvall | 0:b77503796c51 | 40 | |
alindvall | 0:b77503796c51 | 41 | #define USBH_CONNECTION_EVENT (1) |
alindvall | 0:b77503796c51 | 42 | |
alindvall | 0:b77503796c51 | 43 | #define QSPIFS_SIZE_MB (8) |
alindvall | 0:b77503796c51 | 44 | #define QSPIFS_SIZE (QSPIFS_SIZE_MB * 1024*1024) |
alindvall | 0:b77503796c51 | 45 | |
alindvall | 0:b77503796c51 | 46 | /****************************************************************************** |
alindvall | 0:b77503796c51 | 47 | * Local variables |
alindvall | 0:b77503796c51 | 48 | *****************************************************************************/ |
alindvall | 0:b77503796c51 | 49 | |
alindvall | 0:b77503796c51 | 50 | static bench_input_t BENCHMARK_INPUT[] = { |
embeddedartists | 3:1716747cba16 | 51 | // The _red_ images |
alindvall | 0:b77503796c51 | 52 | { |
embeddedartists | 3:1716747cba16 | 53 | .rw = true, |
embeddedartists | 3:1716747cba16 | 54 | .size = img_size_iflash_32x32_red_bmp, |
embeddedartists | 3:1716747cba16 | 55 | .fname = "32x32_red.bmp", |
embeddedartists | 3:1716747cba16 | 56 | .iflash_direct = img_iflash_32x32_red_bmp, |
embeddedartists | 3:1716747cba16 | 57 | .qspi_direct = img_qspi_32x32_red_bmp, |
embeddedartists | 3:1716747cba16 | 58 | }, |
embeddedartists | 3:1716747cba16 | 59 | { |
embeddedartists | 3:1716747cba16 | 60 | .rw = false, |
embeddedartists | 3:1716747cba16 | 61 | .size = img_size_iflash_32x32_red_png, |
embeddedartists | 3:1716747cba16 | 62 | .fname = "32x32_red.png", |
embeddedartists | 3:1716747cba16 | 63 | .iflash_direct = img_iflash_32x32_red_png, |
embeddedartists | 3:1716747cba16 | 64 | .qspi_direct = img_qspi_32x32_red_png, |
embeddedartists | 3:1716747cba16 | 65 | }, |
embeddedartists | 3:1716747cba16 | 66 | { |
embeddedartists | 3:1716747cba16 | 67 | .rw = false, |
embeddedartists | 3:1716747cba16 | 68 | .size = img_size_iflash_32x32_red_raw, |
embeddedartists | 3:1716747cba16 | 69 | .fname = "32x32_red.raw", |
embeddedartists | 3:1716747cba16 | 70 | .iflash_direct = img_iflash_32x32_red_raw, |
embeddedartists | 3:1716747cba16 | 71 | .qspi_direct = img_qspi_32x32_red_raw, |
embeddedartists | 3:1716747cba16 | 72 | }, |
embeddedartists | 3:1716747cba16 | 73 | { |
embeddedartists | 3:1716747cba16 | 74 | .rw = true, |
embeddedartists | 3:1716747cba16 | 75 | .size = img_size_iflash_64x64_red_bmp, |
embeddedartists | 3:1716747cba16 | 76 | .fname = "64x64_red.bmp", |
embeddedartists | 3:1716747cba16 | 77 | .iflash_direct = img_iflash_64x64_red_bmp, |
embeddedartists | 3:1716747cba16 | 78 | .qspi_direct = img_qspi_64x64_red_bmp, |
embeddedartists | 3:1716747cba16 | 79 | }, |
embeddedartists | 3:1716747cba16 | 80 | { |
embeddedartists | 3:1716747cba16 | 81 | .rw = false, |
embeddedartists | 3:1716747cba16 | 82 | .size = img_size_iflash_64x64_red_png, |
embeddedartists | 3:1716747cba16 | 83 | .fname = "64x64_red.png", |
embeddedartists | 3:1716747cba16 | 84 | .iflash_direct = img_iflash_64x64_red_png, |
embeddedartists | 3:1716747cba16 | 85 | .qspi_direct = img_qspi_64x64_red_png, |
embeddedartists | 3:1716747cba16 | 86 | }, |
embeddedartists | 3:1716747cba16 | 87 | { |
embeddedartists | 3:1716747cba16 | 88 | .rw = false, |
embeddedartists | 3:1716747cba16 | 89 | .size = img_size_iflash_64x64_red_raw, |
embeddedartists | 3:1716747cba16 | 90 | .fname = "64x64_red.raw", |
embeddedartists | 3:1716747cba16 | 91 | .iflash_direct = img_iflash_64x64_red_raw, |
embeddedartists | 3:1716747cba16 | 92 | .qspi_direct = img_qspi_64x64_red_raw, |
alindvall | 0:b77503796c51 | 93 | }, |
alindvall | 0:b77503796c51 | 94 | { |
embeddedartists | 3:1716747cba16 | 95 | .rw = true, |
embeddedartists | 3:1716747cba16 | 96 | .size = img_size_qspi_128x128_red_bmp, |
embeddedartists | 3:1716747cba16 | 97 | .fname = "128x128_red.bmp", |
embeddedartists | 3:1716747cba16 | 98 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 99 | .qspi_direct = img_qspi_128x128_red_bmp, |
embeddedartists | 3:1716747cba16 | 100 | }, |
embeddedartists | 3:1716747cba16 | 101 | { |
embeddedartists | 3:1716747cba16 | 102 | .rw = false, |
embeddedartists | 3:1716747cba16 | 103 | .size = img_size_qspi_128x128_red_png, |
embeddedartists | 3:1716747cba16 | 104 | .fname = "128x128_red.png", |
embeddedartists | 3:1716747cba16 | 105 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 106 | .qspi_direct = img_qspi_128x128_red_png, |
embeddedartists | 3:1716747cba16 | 107 | }, |
embeddedartists | 3:1716747cba16 | 108 | { |
embeddedartists | 3:1716747cba16 | 109 | .rw = false, |
embeddedartists | 3:1716747cba16 | 110 | .size = img_size_qspi_128x128_red_raw, |
embeddedartists | 3:1716747cba16 | 111 | .fname = "128x128_red.raw", |
embeddedartists | 3:1716747cba16 | 112 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 113 | .qspi_direct = img_qspi_128x128_red_raw, |
embeddedartists | 3:1716747cba16 | 114 | }, |
embeddedartists | 3:1716747cba16 | 115 | { |
embeddedartists | 3:1716747cba16 | 116 | .rw = false, |
embeddedartists | 3:1716747cba16 | 117 | .size = img_size_qspi_480x272_red_bmp, |
embeddedartists | 3:1716747cba16 | 118 | .fname = "480x272_red.bmp", |
embeddedartists | 3:1716747cba16 | 119 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 120 | .qspi_direct = img_qspi_480x272_red_bmp, |
embeddedartists | 3:1716747cba16 | 121 | }, |
embeddedartists | 3:1716747cba16 | 122 | { |
embeddedartists | 3:1716747cba16 | 123 | .rw = false, |
embeddedartists | 3:1716747cba16 | 124 | .size = img_size_qspi_480x272_red_png, |
embeddedartists | 3:1716747cba16 | 125 | .fname = "480x272_red.png", |
embeddedartists | 3:1716747cba16 | 126 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 127 | .qspi_direct = img_qspi_480x272_red_png, |
embeddedartists | 3:1716747cba16 | 128 | }, |
embeddedartists | 3:1716747cba16 | 129 | { |
embeddedartists | 3:1716747cba16 | 130 | .rw = true, |
embeddedartists | 3:1716747cba16 | 131 | .size = img_size_qspi_480x272_red_raw, |
embeddedartists | 3:1716747cba16 | 132 | .fname = "480x272_red.raw", |
embeddedartists | 3:1716747cba16 | 133 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 134 | .qspi_direct = img_qspi_480x272_red_raw, |
embeddedartists | 3:1716747cba16 | 135 | }, |
embeddedartists | 3:1716747cba16 | 136 | { |
embeddedartists | 3:1716747cba16 | 137 | .rw = true, |
embeddedartists | 3:1716747cba16 | 138 | .size = img_size_qspi_800x480_red_bmp, |
embeddedartists | 3:1716747cba16 | 139 | .fname = "800x480_red.bmp", |
embeddedartists | 3:1716747cba16 | 140 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 141 | .qspi_direct = img_qspi_800x480_red_bmp, |
embeddedartists | 3:1716747cba16 | 142 | }, |
embeddedartists | 3:1716747cba16 | 143 | { |
embeddedartists | 3:1716747cba16 | 144 | .rw = false, |
embeddedartists | 3:1716747cba16 | 145 | .size = img_size_qspi_800x480_red_png, |
embeddedartists | 3:1716747cba16 | 146 | .fname = "800x480_red.png", |
embeddedartists | 3:1716747cba16 | 147 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 148 | .qspi_direct = img_qspi_800x480_red_png, |
alindvall | 0:b77503796c51 | 149 | }, |
alindvall | 0:b77503796c51 | 150 | { |
embeddedartists | 3:1716747cba16 | 151 | .rw = false, |
embeddedartists | 3:1716747cba16 | 152 | .size = img_size_qspi_800x480_red_raw, |
embeddedartists | 3:1716747cba16 | 153 | .fname = "800x480_red.raw", |
embeddedartists | 3:1716747cba16 | 154 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 155 | .qspi_direct = img_qspi_800x480_red_raw, |
embeddedartists | 3:1716747cba16 | 156 | }, |
embeddedartists | 3:1716747cba16 | 157 | |
embeddedartists | 3:1716747cba16 | 158 | // The _flowers_ images |
embeddedartists | 3:1716747cba16 | 159 | { |
embeddedartists | 3:1716747cba16 | 160 | .rw = false, |
embeddedartists | 3:1716747cba16 | 161 | .size = img_size_iflash_32x32_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 162 | .fname = "32x32_flowers.bmp", |
embeddedartists | 3:1716747cba16 | 163 | .iflash_direct = img_iflash_32x32_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 164 | .qspi_direct = img_qspi_32x32_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 165 | }, |
embeddedartists | 3:1716747cba16 | 166 | { |
embeddedartists | 3:1716747cba16 | 167 | .rw = false, |
embeddedartists | 3:1716747cba16 | 168 | .size = img_size_iflash_32x32_flowers_png, |
embeddedartists | 3:1716747cba16 | 169 | .fname = "32x32_flowers.png", |
embeddedartists | 3:1716747cba16 | 170 | .iflash_direct = img_iflash_32x32_flowers_png, |
embeddedartists | 3:1716747cba16 | 171 | .qspi_direct = img_qspi_32x32_flowers_png, |
alindvall | 0:b77503796c51 | 172 | }, |
alindvall | 0:b77503796c51 | 173 | { |
embeddedartists | 3:1716747cba16 | 174 | .rw = false, |
embeddedartists | 3:1716747cba16 | 175 | .size = img_size_iflash_32x32_flowers_raw, |
embeddedartists | 3:1716747cba16 | 176 | .fname = "32x32_flowers.raw", |
embeddedartists | 3:1716747cba16 | 177 | .iflash_direct = img_iflash_32x32_flowers_raw, |
embeddedartists | 3:1716747cba16 | 178 | .qspi_direct = img_qspi_32x32_flowers_raw, |
embeddedartists | 3:1716747cba16 | 179 | }, |
embeddedartists | 3:1716747cba16 | 180 | { |
embeddedartists | 3:1716747cba16 | 181 | .rw = false, |
embeddedartists | 3:1716747cba16 | 182 | .size = img_size_iflash_64x64_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 183 | .fname = "64x64_flowers.bmp", |
embeddedartists | 3:1716747cba16 | 184 | .iflash_direct = img_iflash_64x64_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 185 | .qspi_direct = img_qspi_64x64_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 186 | }, |
embeddedartists | 3:1716747cba16 | 187 | { |
embeddedartists | 3:1716747cba16 | 188 | .rw = false, |
embeddedartists | 3:1716747cba16 | 189 | .size = img_size_iflash_64x64_flowers_png, |
embeddedartists | 3:1716747cba16 | 190 | .fname = "64x64_flowers.png", |
embeddedartists | 3:1716747cba16 | 191 | .iflash_direct = img_iflash_64x64_flowers_png, |
embeddedartists | 3:1716747cba16 | 192 | .qspi_direct = img_qspi_64x64_flowers_png, |
embeddedartists | 3:1716747cba16 | 193 | }, |
embeddedartists | 3:1716747cba16 | 194 | { |
embeddedartists | 3:1716747cba16 | 195 | .rw = false, |
embeddedartists | 3:1716747cba16 | 196 | .size = img_size_iflash_64x64_flowers_raw, |
embeddedartists | 3:1716747cba16 | 197 | .fname = "64x64_flowers.raw", |
embeddedartists | 3:1716747cba16 | 198 | .iflash_direct = img_iflash_64x64_flowers_raw, |
embeddedartists | 3:1716747cba16 | 199 | .qspi_direct = img_qspi_64x64_flowers_raw, |
alindvall | 0:b77503796c51 | 200 | }, |
alindvall | 0:b77503796c51 | 201 | { |
embeddedartists | 3:1716747cba16 | 202 | .rw = false, |
embeddedartists | 3:1716747cba16 | 203 | .size = img_size_qspi_128x128_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 204 | .fname = "128x128_flowers.bmp", |
embeddedartists | 3:1716747cba16 | 205 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 206 | .qspi_direct = img_qspi_128x128_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 207 | }, |
embeddedartists | 3:1716747cba16 | 208 | { |
embeddedartists | 3:1716747cba16 | 209 | .rw = false, |
embeddedartists | 3:1716747cba16 | 210 | .size = img_size_qspi_128x128_flowers_png, |
embeddedartists | 3:1716747cba16 | 211 | .fname = "128x128_flowers.png", |
alindvall | 0:b77503796c51 | 212 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 213 | .qspi_direct = img_qspi_128x128_flowers_png, |
embeddedartists | 3:1716747cba16 | 214 | }, |
embeddedartists | 3:1716747cba16 | 215 | { |
embeddedartists | 3:1716747cba16 | 216 | .rw = false, |
embeddedartists | 3:1716747cba16 | 217 | .size = img_size_qspi_128x128_flowers_raw, |
embeddedartists | 3:1716747cba16 | 218 | .fname = "128x128_flowers.raw", |
embeddedartists | 3:1716747cba16 | 219 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 220 | .qspi_direct = img_qspi_128x128_flowers_raw, |
embeddedartists | 3:1716747cba16 | 221 | }, |
embeddedartists | 3:1716747cba16 | 222 | { |
embeddedartists | 3:1716747cba16 | 223 | .rw = false, |
embeddedartists | 3:1716747cba16 | 224 | .size = img_size_qspi_480x272_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 225 | .fname = "480x272_flowers.bmp", |
embeddedartists | 3:1716747cba16 | 226 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 227 | .qspi_direct = img_qspi_480x272_flowers_bmp, |
alindvall | 0:b77503796c51 | 228 | }, |
alindvall | 0:b77503796c51 | 229 | { |
embeddedartists | 3:1716747cba16 | 230 | .rw = false, |
embeddedartists | 3:1716747cba16 | 231 | .size = img_size_qspi_480x272_flowers_png, |
embeddedartists | 3:1716747cba16 | 232 | .fname = "480x272_flowers.png", |
embeddedartists | 3:1716747cba16 | 233 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 234 | .qspi_direct = img_qspi_480x272_flowers_png, |
embeddedartists | 3:1716747cba16 | 235 | }, |
embeddedartists | 3:1716747cba16 | 236 | { |
embeddedartists | 3:1716747cba16 | 237 | .rw = false, |
embeddedartists | 3:1716747cba16 | 238 | .size = img_size_qspi_480x272_flowers_raw, |
embeddedartists | 3:1716747cba16 | 239 | .fname = "480x272_flowers.raw", |
alindvall | 0:b77503796c51 | 240 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 241 | .qspi_direct = img_qspi_480x272_flowers_raw, |
embeddedartists | 3:1716747cba16 | 242 | }, |
embeddedartists | 3:1716747cba16 | 243 | { |
embeddedartists | 3:1716747cba16 | 244 | .rw = false, |
embeddedartists | 3:1716747cba16 | 245 | .size = img_size_qspi_800x480_flowers_bmp, |
embeddedartists | 3:1716747cba16 | 246 | .fname = "800x480_flowers.bmp", |
embeddedartists | 3:1716747cba16 | 247 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 248 | .qspi_direct = img_qspi_800x480_flowers_bmp, |
alindvall | 0:b77503796c51 | 249 | }, |
embeddedartists | 3:1716747cba16 | 250 | { |
embeddedartists | 3:1716747cba16 | 251 | .rw = false, |
embeddedartists | 3:1716747cba16 | 252 | .size = img_size_qspi_800x480_flowers_png, |
embeddedartists | 3:1716747cba16 | 253 | .fname = "800x480_flowers.png", |
embeddedartists | 3:1716747cba16 | 254 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 255 | .qspi_direct = img_qspi_800x480_flowers_png, |
embeddedartists | 3:1716747cba16 | 256 | }, |
embeddedartists | 3:1716747cba16 | 257 | { |
embeddedartists | 3:1716747cba16 | 258 | .rw = false, |
embeddedartists | 3:1716747cba16 | 259 | .size = img_size_qspi_800x480_flowers_raw, |
embeddedartists | 3:1716747cba16 | 260 | .fname = "800x480_flowers.raw", |
embeddedartists | 3:1716747cba16 | 261 | .iflash_direct = NULL, |
embeddedartists | 3:1716747cba16 | 262 | .qspi_direct = img_qspi_800x480_flowers_raw, |
embeddedartists | 3:1716747cba16 | 263 | }, |
alindvall | 0:b77503796c51 | 264 | }; |
alindvall | 0:b77503796c51 | 265 | |
alindvall | 0:b77503796c51 | 266 | static MCIFileSystem* mcifs; |
alindvall | 0:b77503796c51 | 267 | static QSPIFileSystem* qspifs; |
alindvall | 0:b77503796c51 | 268 | static USBHostMSD* usbmsd; |
alindvall | 0:b77503796c51 | 269 | |
alindvall | 0:b77503796c51 | 270 | /****************************************************************************** |
alindvall | 0:b77503796c51 | 271 | * Private Functions |
alindvall | 0:b77503796c51 | 272 | *****************************************************************************/ |
alindvall | 0:b77503796c51 | 273 | |
alindvall | 0:b77503796c51 | 274 | |
alindvall | 0:b77503796c51 | 275 | static bool fileExists(const char* fname) { |
alindvall | 0:b77503796c51 | 276 | FILE* f = fopen(fname, "r"); |
alindvall | 0:b77503796c51 | 277 | if (f != NULL) { |
alindvall | 0:b77503796c51 | 278 | fclose(f); |
alindvall | 0:b77503796c51 | 279 | return true; |
alindvall | 0:b77503796c51 | 280 | } |
alindvall | 0:b77503796c51 | 281 | return false; |
alindvall | 0:b77503796c51 | 282 | } |
alindvall | 0:b77503796c51 | 283 | |
alindvall | 0:b77503796c51 | 284 | static bool haveAllFiles(const char* prefix) { |
alindvall | 0:b77503796c51 | 285 | char buff[512] = {0}; |
alindvall | 0:b77503796c51 | 286 | strcpy(buff, prefix); |
alindvall | 0:b77503796c51 | 287 | int len = strlen(buff); |
alindvall | 0:b77503796c51 | 288 | |
alindvall | 0:b77503796c51 | 289 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
alindvall | 0:b77503796c51 | 290 | strcpy(buff+len, BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 291 | if (!fileExists(buff)) { |
alindvall | 0:b77503796c51 | 292 | DMBoard::instance().logger()->printf("File %s is missing\n", buff); |
alindvall | 0:b77503796c51 | 293 | return false; |
alindvall | 0:b77503796c51 | 294 | } |
alindvall | 0:b77503796c51 | 295 | } |
alindvall | 0:b77503796c51 | 296 | return true; |
alindvall | 0:b77503796c51 | 297 | } |
alindvall | 0:b77503796c51 | 298 | |
alindvall | 0:b77503796c51 | 299 | static bool createFiles(const char* prefix) { |
alindvall | 0:b77503796c51 | 300 | RtosLog* log = DMBoard::instance().logger(); |
alindvall | 0:b77503796c51 | 301 | char buff[512] = {0}; |
alindvall | 0:b77503796c51 | 302 | strcpy(buff, prefix); |
alindvall | 0:b77503796c51 | 303 | int len = strlen(buff); |
alindvall | 0:b77503796c51 | 304 | |
alindvall | 0:b77503796c51 | 305 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
alindvall | 0:b77503796c51 | 306 | strcpy(buff+len, BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 307 | log->printf(" writing %u bytes to %s\n", BENCHMARK_INPUT[i].size, buff); |
alindvall | 0:b77503796c51 | 308 | FILE* f = fopen(buff, "w"); |
alindvall | 0:b77503796c51 | 309 | if (f == NULL) { |
alindvall | 0:b77503796c51 | 310 | log->printf("Failed to create file %s - ABORTING\n", buff); |
alindvall | 0:b77503796c51 | 311 | return false; |
alindvall | 0:b77503796c51 | 312 | } |
alindvall | 0:b77503796c51 | 313 | uint32_t written; |
alindvall | 0:b77503796c51 | 314 | if (BENCHMARK_INPUT[i].iflash_direct == NULL) { |
alindvall | 0:b77503796c51 | 315 | // Need to copy from QSPI to SDRAM before attempting to write to the |
alindvall | 0:b77503796c51 | 316 | // file as it will fail otherwise. |
alindvall | 0:b77503796c51 | 317 | uint8_t* dest = (uint8_t*)malloc(COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 318 | memcpy(dest, BENCHMARK_INPUT[i].qspi_direct, BENCHMARK_INPUT[i].size); |
alindvall | 0:b77503796c51 | 319 | written = fwrite(dest, 1, BENCHMARK_INPUT[i].size, f); |
alindvall | 0:b77503796c51 | 320 | free(dest); |
alindvall | 0:b77503796c51 | 321 | //written = fwrite(BENCHMARK_INPUT[i].qspi_direct, 1, BENCHMARK_INPUT[i].size, f); |
alindvall | 0:b77503796c51 | 322 | } else { |
alindvall | 0:b77503796c51 | 323 | written = fwrite(BENCHMARK_INPUT[i].iflash_direct, 1, BENCHMARK_INPUT[i].size, f); |
alindvall | 0:b77503796c51 | 324 | } |
alindvall | 0:b77503796c51 | 325 | if (written != BENCHMARK_INPUT[i].size) { |
alindvall | 0:b77503796c51 | 326 | log->printf("Failed to write %u (only wrote %u) bytes to %s - ABORTING\n", BENCHMARK_INPUT[i].size, written, buff); |
embeddedartists | 2:ddc1aa3bea3d | 327 | fclose(f); |
alindvall | 0:b77503796c51 | 328 | return false; |
alindvall | 0:b77503796c51 | 329 | } |
alindvall | 0:b77503796c51 | 330 | fclose(f); |
alindvall | 0:b77503796c51 | 331 | } |
alindvall | 0:b77503796c51 | 332 | return true; |
alindvall | 0:b77503796c51 | 333 | } |
alindvall | 0:b77503796c51 | 334 | |
alindvall | 0:b77503796c51 | 335 | static bool prepareMCI() { |
alindvall | 0:b77503796c51 | 336 | RtosLog* log = DMBoard::instance().logger(); |
alindvall | 0:b77503796c51 | 337 | bool ok = false; |
alindvall | 0:b77503796c51 | 338 | |
alindvall | 0:b77503796c51 | 339 | mcifs = new MCIFileSystem("mci", P4_16); |
alindvall | 0:b77503796c51 | 340 | |
alindvall | 0:b77503796c51 | 341 | if (mcifs->cardInserted()) { |
alindvall | 0:b77503796c51 | 342 | log->printf("uSD card detected\n"); |
alindvall | 0:b77503796c51 | 343 | |
alindvall | 0:b77503796c51 | 344 | if (haveAllFiles("/mci/")) { |
alindvall | 0:b77503796c51 | 345 | log->printf("uSD file system prepared!\n"); |
alindvall | 0:b77503796c51 | 346 | ok = true; |
alindvall | 0:b77503796c51 | 347 | } else { |
alindvall | 0:b77503796c51 | 348 | log->printf("One or more files missing, need to (re-)prepare the uSD file system\n"); |
alindvall | 0:b77503796c51 | 349 | |
alindvall | 0:b77503796c51 | 350 | log->printf("Preparing uSD file system...\n"); |
alindvall | 0:b77503796c51 | 351 | if (createFiles("/mci/")) { |
alindvall | 0:b77503796c51 | 352 | log->printf("uSD file system prepared!\n"); |
alindvall | 0:b77503796c51 | 353 | ok = true; |
alindvall | 0:b77503796c51 | 354 | } else { |
alindvall | 0:b77503796c51 | 355 | log->printf("Failed to prepare uSD file system!\n"); |
alindvall | 0:b77503796c51 | 356 | } |
alindvall | 0:b77503796c51 | 357 | } |
alindvall | 0:b77503796c51 | 358 | } else { |
alindvall | 0:b77503796c51 | 359 | log->printf("No uSD card detected. Insert one and reset\n"); |
alindvall | 0:b77503796c51 | 360 | } |
alindvall | 0:b77503796c51 | 361 | |
alindvall | 0:b77503796c51 | 362 | return ok; |
alindvall | 0:b77503796c51 | 363 | } |
alindvall | 0:b77503796c51 | 364 | |
alindvall | 0:b77503796c51 | 365 | static bool prepareUSB() { |
alindvall | 0:b77503796c51 | 366 | RtosLog* log = DMBoard::instance().logger(); |
alindvall | 0:b77503796c51 | 367 | bool ok = false; |
alindvall | 0:b77503796c51 | 368 | |
alindvall | 0:b77503796c51 | 369 | usbmsd = new USBHostMSD("usb"); |
alindvall | 0:b77503796c51 | 370 | USBHost* host = USBHost::getHostInst(); |
alindvall | 0:b77503796c51 | 371 | host->signalOnConnections(Thread::gettid(), USBH_CONNECTION_EVENT); |
alindvall | 0:b77503796c51 | 372 | |
alindvall | 0:b77503796c51 | 373 | log->printf("waiting for connect/disconnect message from USBHost...\n"); |
alindvall | 0:b77503796c51 | 374 | Thread::signal_wait(USBH_CONNECTION_EVENT); |
alindvall | 0:b77503796c51 | 375 | |
alindvall | 0:b77503796c51 | 376 | if (usbmsd->connect()) { |
alindvall | 0:b77503796c51 | 377 | log->printf("USB MemoryStick detected\n"); |
alindvall | 0:b77503796c51 | 378 | |
alindvall | 0:b77503796c51 | 379 | if (haveAllFiles("/usb/")) { |
alindvall | 0:b77503796c51 | 380 | log->printf("USB MemoryStick file system prepared!\n"); |
alindvall | 0:b77503796c51 | 381 | ok = true; |
alindvall | 0:b77503796c51 | 382 | } else { |
alindvall | 0:b77503796c51 | 383 | log->printf("One or more files missing, need to (re-)prepare the USB MemoryStick\n"); |
alindvall | 0:b77503796c51 | 384 | |
alindvall | 0:b77503796c51 | 385 | log->printf("Preparing USB MemoryStick file system...\n"); |
alindvall | 0:b77503796c51 | 386 | if (createFiles("/usb/")) { |
alindvall | 0:b77503796c51 | 387 | log->printf("USB MemoryStick file system prepared!\n"); |
alindvall | 0:b77503796c51 | 388 | ok = true; |
alindvall | 0:b77503796c51 | 389 | } else { |
alindvall | 0:b77503796c51 | 390 | log->printf("Failed to prepare USB MemoryStick file system!\n"); |
alindvall | 0:b77503796c51 | 391 | } |
alindvall | 0:b77503796c51 | 392 | } |
alindvall | 0:b77503796c51 | 393 | } else { |
alindvall | 0:b77503796c51 | 394 | log->printf("No USB MemoryStick detected. Insert one and reset\n"); |
alindvall | 0:b77503796c51 | 395 | } |
alindvall | 0:b77503796c51 | 396 | |
alindvall | 0:b77503796c51 | 397 | return ok; |
alindvall | 0:b77503796c51 | 398 | } |
alindvall | 0:b77503796c51 | 399 | |
alindvall | 0:b77503796c51 | 400 | static bool prepareQSPIFS() { |
alindvall | 0:b77503796c51 | 401 | RtosLog* log = DMBoard::instance().logger(); |
alindvall | 0:b77503796c51 | 402 | bool ok = false; |
alindvall | 0:b77503796c51 | 403 | bool format = false; |
alindvall | 0:b77503796c51 | 404 | |
alindvall | 0:b77503796c51 | 405 | qspifs = new QSPIFileSystem("qspi"); |
alindvall | 0:b77503796c51 | 406 | |
alindvall | 0:b77503796c51 | 407 | do { |
alindvall | 0:b77503796c51 | 408 | if (qspifs->isformatted()) { |
alindvall | 0:b77503796c51 | 409 | uint32_t start, end; |
alindvall | 0:b77503796c51 | 410 | qspifs->getMemoryBoundaries(&start, &end); |
alindvall | 0:b77503796c51 | 411 | if ((end-start) >= QSPIFS_SIZE) { |
alindvall | 0:b77503796c51 | 412 | log->printf("QSPI file system detected\n"); |
alindvall | 0:b77503796c51 | 413 | |
alindvall | 0:b77503796c51 | 414 | if (haveAllFiles("/qspi/")) { |
alindvall | 0:b77503796c51 | 415 | log->printf("QSPI file system prepared!\n"); |
alindvall | 0:b77503796c51 | 416 | ok = true; |
alindvall | 0:b77503796c51 | 417 | break; |
alindvall | 0:b77503796c51 | 418 | } else { |
alindvall | 0:b77503796c51 | 419 | log->printf("One or more files missing, need to (re-)prepare the QSPI file system\n"); |
embeddedartists | 3:1716747cba16 | 420 | format = true; |
alindvall | 0:b77503796c51 | 421 | } |
alindvall | 0:b77503796c51 | 422 | } else { |
alindvall | 0:b77503796c51 | 423 | log->printf("Found too small file system (only %dMB). Formatting...\n", (end-start)/(1024*1024)); |
alindvall | 0:b77503796c51 | 424 | format = true; |
alindvall | 0:b77503796c51 | 425 | } |
alindvall | 0:b77503796c51 | 426 | } else { |
alindvall | 0:b77503796c51 | 427 | log->printf("No QSPI file system detected. Formatting...\n"); |
alindvall | 0:b77503796c51 | 428 | format = true; |
alindvall | 0:b77503796c51 | 429 | } |
alindvall | 0:b77503796c51 | 430 | |
alindvall | 0:b77503796c51 | 431 | if (format) { |
alindvall | 0:b77503796c51 | 432 | if (qspifs->format(QSPIFS_SIZE_MB) == 0) { |
alindvall | 0:b77503796c51 | 433 | log->printf("Formatting successful\n"); |
alindvall | 0:b77503796c51 | 434 | } else { |
alindvall | 0:b77503796c51 | 435 | log->printf("Failed to format QSPI file system!\n"); |
alindvall | 0:b77503796c51 | 436 | break; |
alindvall | 0:b77503796c51 | 437 | } |
alindvall | 0:b77503796c51 | 438 | } |
alindvall | 0:b77503796c51 | 439 | |
alindvall | 0:b77503796c51 | 440 | log->printf("Preparing QSPI file system...\n"); |
alindvall | 0:b77503796c51 | 441 | if (createFiles("/qspi/")) { |
alindvall | 0:b77503796c51 | 442 | log->printf("QSPI file system prepared!\n"); |
alindvall | 0:b77503796c51 | 443 | ok = true; |
alindvall | 0:b77503796c51 | 444 | } else { |
alindvall | 0:b77503796c51 | 445 | log->printf("Failed to prepare QSPI file system!\n"); |
alindvall | 0:b77503796c51 | 446 | } |
alindvall | 0:b77503796c51 | 447 | } while(false); |
alindvall | 0:b77503796c51 | 448 | |
alindvall | 0:b77503796c51 | 449 | return ok; |
alindvall | 0:b77503796c51 | 450 | } |
alindvall | 0:b77503796c51 | 451 | |
alindvall | 0:b77503796c51 | 452 | static bool prepare() { |
embeddedartists | 1:b000ac168e46 | 453 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 1:b000ac168e46 | 454 | |
embeddedartists | 1:b000ac168e46 | 455 | // make sure that the linker actually placed the data in the |
embeddedartists | 1:b000ac168e46 | 456 | // correct flashes |
embeddedartists | 1:b000ac168e46 | 457 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 1:b000ac168e46 | 458 | if (BENCHMARK_INPUT[i].iflash_direct != NULL) { |
embeddedartists | 1:b000ac168e46 | 459 | uint32_t tmp = (uint32_t)BENCHMARK_INPUT[i].iflash_direct; |
embeddedartists | 1:b000ac168e46 | 460 | if ((tmp & 0xff000000) != 0x00000000) { |
embeddedartists | 1:b000ac168e46 | 461 | log->printf("IFLASH data for benchmark %d is at 0x%08x NOT in IFLASH!! Aborting\n", i, tmp); |
embeddedartists | 1:b000ac168e46 | 462 | return false; |
embeddedartists | 1:b000ac168e46 | 463 | } |
embeddedartists | 1:b000ac168e46 | 464 | tmp = (uint32_t)BENCHMARK_INPUT[i].qspi_direct; |
embeddedartists | 1:b000ac168e46 | 465 | if ((tmp & 0xff000000) != 0x28000000) { |
embeddedartists | 1:b000ac168e46 | 466 | log->printf("QSPI data for benchmark %d is at 0x%08x NOT in QSPI!! Aborting\n", i, tmp); |
embeddedartists | 1:b000ac168e46 | 467 | return false; |
embeddedartists | 1:b000ac168e46 | 468 | } |
embeddedartists | 1:b000ac168e46 | 469 | } |
embeddedartists | 1:b000ac168e46 | 470 | } |
alindvall | 0:b77503796c51 | 471 | return prepareMCI() && prepareUSB() && prepareQSPIFS(); |
alindvall | 0:b77503796c51 | 472 | } |
alindvall | 0:b77503796c51 | 473 | |
alindvall | 0:b77503796c51 | 474 | static void readFile(const char* fname, uint8_t* dest) { |
alindvall | 0:b77503796c51 | 475 | FILE* f = fopen(fname, "r"); |
alindvall | 0:b77503796c51 | 476 | if (f != NULL) { |
alindvall | 0:b77503796c51 | 477 | int num = fread(dest, 1, 1024, f); |
alindvall | 0:b77503796c51 | 478 | while (num > 0) { |
alindvall | 0:b77503796c51 | 479 | dest+=num; |
alindvall | 0:b77503796c51 | 480 | num = fread(dest, 1, 1024, f); |
alindvall | 0:b77503796c51 | 481 | } |
alindvall | 0:b77503796c51 | 482 | fclose(f); |
alindvall | 0:b77503796c51 | 483 | } |
alindvall | 0:b77503796c51 | 484 | } |
alindvall | 0:b77503796c51 | 485 | |
embeddedartists | 2:ddc1aa3bea3d | 486 | static void runReadBenchmarks() { |
alindvall | 0:b77503796c51 | 487 | RtosLog* log = DMBoard::instance().logger(); |
alindvall | 0:b77503796c51 | 488 | uint32_t times[NUM_BENCHMARKS][5] = {0}; |
alindvall | 0:b77503796c51 | 489 | uint32_t tmp; |
alindvall | 0:b77503796c51 | 490 | char buff[512]; |
alindvall | 0:b77503796c51 | 491 | Timer t; |
alindvall | 0:b77503796c51 | 492 | uint8_t* dest = (uint8_t*)malloc(COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 493 | if (dest == NULL) { |
alindvall | 0:b77503796c51 | 494 | log->printf("Failed to allocate 10MBytes as buffer\n"); |
alindvall | 0:b77503796c51 | 495 | return; |
alindvall | 0:b77503796c51 | 496 | } |
alindvall | 0:b77503796c51 | 497 | |
alindvall | 0:b77503796c51 | 498 | t.start(); |
alindvall | 0:b77503796c51 | 499 | |
alindvall | 0:b77503796c51 | 500 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 501 | if (!BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 502 | // don't include the files for the image decoding in |
embeddedartists | 3:1716747cba16 | 503 | // the benchmark set |
embeddedartists | 3:1716747cba16 | 504 | continue; |
embeddedartists | 3:1716747cba16 | 505 | } |
embeddedartists | 3:1716747cba16 | 506 | |
alindvall | 0:b77503796c51 | 507 | // MCI |
alindvall | 0:b77503796c51 | 508 | sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 509 | memset(dest, 0, COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 510 | tmp = t.read_us(); |
alindvall | 0:b77503796c51 | 511 | readFile(buff, dest); |
alindvall | 0:b77503796c51 | 512 | times[i][0] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 513 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][0]); |
alindvall | 0:b77503796c51 | 514 | |
alindvall | 0:b77503796c51 | 515 | //USB |
alindvall | 0:b77503796c51 | 516 | sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 517 | memset(dest, 0, COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 518 | tmp = t.read_us(); |
alindvall | 0:b77503796c51 | 519 | readFile(buff, dest); |
alindvall | 0:b77503796c51 | 520 | times[i][1] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 521 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][1]); |
alindvall | 0:b77503796c51 | 522 | |
alindvall | 0:b77503796c51 | 523 | //QSPIFS |
alindvall | 0:b77503796c51 | 524 | sprintf(buff, "/qspi/%s", BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 525 | memset(dest, 0, COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 526 | tmp = t.read_us(); |
alindvall | 0:b77503796c51 | 527 | readFile(buff, dest); |
alindvall | 0:b77503796c51 | 528 | times[i][2] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 529 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][2]); |
alindvall | 0:b77503796c51 | 530 | |
alindvall | 0:b77503796c51 | 531 | //IFLASH |
alindvall | 0:b77503796c51 | 532 | sprintf(buff, "IFLASH /%s", BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 533 | if (BENCHMARK_INPUT[i].iflash_direct != NULL) { |
alindvall | 0:b77503796c51 | 534 | memset(dest, 0, COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 535 | tmp = t.read_us(); |
alindvall | 0:b77503796c51 | 536 | memcpy(dest, BENCHMARK_INPUT[i].iflash_direct, BENCHMARK_INPUT[i].size); |
alindvall | 0:b77503796c51 | 537 | times[i][3] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 538 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][3]); |
alindvall | 0:b77503796c51 | 539 | } else { |
embeddedartists | 3:1716747cba16 | 540 | log->printf("Benchmarking %-30s skipped\n", buff); |
alindvall | 0:b77503796c51 | 541 | } |
alindvall | 0:b77503796c51 | 542 | |
alindvall | 0:b77503796c51 | 543 | //QSPI |
alindvall | 0:b77503796c51 | 544 | sprintf(buff, "QSPI /%s", BENCHMARK_INPUT[i].fname); |
alindvall | 0:b77503796c51 | 545 | if (BENCHMARK_INPUT[i].qspi_direct != NULL) { |
alindvall | 0:b77503796c51 | 546 | memset(dest, 0, COPYBUF_SIZE); |
alindvall | 0:b77503796c51 | 547 | tmp = t.read_us(); |
alindvall | 0:b77503796c51 | 548 | memcpy(dest, BENCHMARK_INPUT[i].qspi_direct, BENCHMARK_INPUT[i].size); |
alindvall | 0:b77503796c51 | 549 | times[i][4] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 550 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][4]); |
alindvall | 0:b77503796c51 | 551 | } else { |
embeddedartists | 3:1716747cba16 | 552 | log->printf("Benchmarking %-30s skipped\n", buff); |
alindvall | 0:b77503796c51 | 553 | } |
alindvall | 0:b77503796c51 | 554 | } |
alindvall | 0:b77503796c51 | 555 | |
alindvall | 0:b77503796c51 | 556 | log->printf("\n\n----\nSummary:\n"); |
alindvall | 0:b77503796c51 | 557 | |
alindvall | 0:b77503796c51 | 558 | log->printf("\n File Information\n"); |
embeddedartists | 3:1716747cba16 | 559 | log->printf("%20s %10s\n", "Filename", "Size"); |
embeddedartists | 3:1716747cba16 | 560 | log->printf("%20s %10s\n", "--------", "----"); |
alindvall | 0:b77503796c51 | 561 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 562 | if (BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 563 | log->printf("%20s %10d bytes\n", BENCHMARK_INPUT[i].fname, BENCHMARK_INPUT[i].size); |
embeddedartists | 3:1716747cba16 | 564 | } |
alindvall | 0:b77503796c51 | 565 | } |
alindvall | 0:b77503796c51 | 566 | |
alindvall | 0:b77503796c51 | 567 | log->printf("\n Read times (in us)\n"); |
embeddedartists | 3:1716747cba16 | 568 | log->printf("%20s %10s %10s %10s %10s %10s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]"); |
embeddedartists | 3:1716747cba16 | 569 | log->printf("%20s %10s %10s %10s %10s %10s\n", "--------", "--------", "---", "-------", "--------", "------"); |
alindvall | 0:b77503796c51 | 570 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 571 | if (BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 572 | char* p = (char*)dest; |
embeddedartists | 3:1716747cba16 | 573 | for (int x = 0; x < 5; x++) { |
embeddedartists | 3:1716747cba16 | 574 | if (times[i][x] == 0) { |
embeddedartists | 3:1716747cba16 | 575 | p += sprintf(p, "%10s ", "N/A"); |
embeddedartists | 3:1716747cba16 | 576 | } else { |
embeddedartists | 3:1716747cba16 | 577 | p += sprintf(p, "%10d ", times[i][x]); |
embeddedartists | 3:1716747cba16 | 578 | } |
alindvall | 0:b77503796c51 | 579 | } |
embeddedartists | 3:1716747cba16 | 580 | log->printf("%20s %s\n", BENCHMARK_INPUT[i].fname, dest); |
alindvall | 0:b77503796c51 | 581 | } |
alindvall | 0:b77503796c51 | 582 | } |
alindvall | 0:b77503796c51 | 583 | |
alindvall | 0:b77503796c51 | 584 | log->printf("\n Read speeds\n"); |
embeddedartists | 3:1716747cba16 | 585 | log->printf("%20s %-12s %-12s %-12s %-12s %-12s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]"); |
embeddedartists | 3:1716747cba16 | 586 | log->printf("%20s %s %s %s %s %s\n", "--------", "------------", "------------", "------------", "------------", "------------"); |
alindvall | 0:b77503796c51 | 587 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 588 | if (BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 589 | char* p = (char*)dest; |
embeddedartists | 3:1716747cba16 | 590 | for (int x = 0; x < 5; x++) { |
embeddedartists | 3:1716747cba16 | 591 | if (times[i][x] == 0) { |
embeddedartists | 3:1716747cba16 | 592 | p += sprintf(p, "%12s ", "N/A "); |
alindvall | 0:b77503796c51 | 593 | } else { |
embeddedartists | 3:1716747cba16 | 594 | double t = times[i][x]; |
embeddedartists | 3:1716747cba16 | 595 | double s = BENCHMARK_INPUT[i].size; |
embeddedartists | 3:1716747cba16 | 596 | double v = (s*1000000)/t; |
embeddedartists | 3:1716747cba16 | 597 | if (v < 10000) { |
embeddedartists | 3:1716747cba16 | 598 | p += sprintf(p, "%#7.2F b/s ", v); |
embeddedartists | 3:1716747cba16 | 599 | } else if (v < 10000000) { |
embeddedartists | 3:1716747cba16 | 600 | p += sprintf(p, "%#7.2F Kb/s ", v/1024.0); |
embeddedartists | 3:1716747cba16 | 601 | } else { |
embeddedartists | 3:1716747cba16 | 602 | p += sprintf(p, "%#7.2F Mb/s ", v/(1024.0*1024.0)); |
embeddedartists | 3:1716747cba16 | 603 | } |
alindvall | 0:b77503796c51 | 604 | } |
alindvall | 0:b77503796c51 | 605 | } |
embeddedartists | 3:1716747cba16 | 606 | log->printf("%20s %s \n", BENCHMARK_INPUT[i].fname, dest); |
alindvall | 0:b77503796c51 | 607 | } |
alindvall | 0:b77503796c51 | 608 | } |
alindvall | 0:b77503796c51 | 609 | |
alindvall | 0:b77503796c51 | 610 | log->printf("\n\n---\n"); |
embeddedartists | 2:ddc1aa3bea3d | 611 | |
embeddedartists | 2:ddc1aa3bea3d | 612 | free(dest); |
embeddedartists | 2:ddc1aa3bea3d | 613 | } |
embeddedartists | 2:ddc1aa3bea3d | 614 | |
embeddedartists | 2:ddc1aa3bea3d | 615 | static uint32_t writeFile(const char* fname, int benchId, Timer* t, uint8_t* buff) { |
embeddedartists | 2:ddc1aa3bea3d | 616 | uint32_t size = BENCHMARK_INPUT[benchId].size; |
embeddedartists | 2:ddc1aa3bea3d | 617 | |
embeddedartists | 2:ddc1aa3bea3d | 618 | // For uSD cards it is not possible to read the data from QSPI flash. |
embeddedartists | 2:ddc1aa3bea3d | 619 | // To make all tests equal all source data is copied to external SDRAM |
embeddedartists | 2:ddc1aa3bea3d | 620 | // and from there to the destination file. Only the time from SDRAM to |
embeddedartists | 2:ddc1aa3bea3d | 621 | // file is meassured. |
embeddedartists | 2:ddc1aa3bea3d | 622 | if (BENCHMARK_INPUT[benchId].iflash_direct == NULL) { |
embeddedartists | 2:ddc1aa3bea3d | 623 | memcpy(buff, BENCHMARK_INPUT[benchId].qspi_direct, size); |
embeddedartists | 2:ddc1aa3bea3d | 624 | } else { |
embeddedartists | 2:ddc1aa3bea3d | 625 | memcpy(buff, BENCHMARK_INPUT[benchId].iflash_direct, size); |
embeddedartists | 2:ddc1aa3bea3d | 626 | } |
embeddedartists | 2:ddc1aa3bea3d | 627 | |
embeddedartists | 2:ddc1aa3bea3d | 628 | uint32_t time = t->read_us(); |
embeddedartists | 2:ddc1aa3bea3d | 629 | int written = 0; |
embeddedartists | 2:ddc1aa3bea3d | 630 | FILE* f = fopen(fname, "w"); |
embeddedartists | 2:ddc1aa3bea3d | 631 | if (f != NULL) { |
embeddedartists | 2:ddc1aa3bea3d | 632 | written = fwrite(buff, 1, size, f); |
embeddedartists | 2:ddc1aa3bea3d | 633 | fclose(f); |
embeddedartists | 2:ddc1aa3bea3d | 634 | } |
embeddedartists | 2:ddc1aa3bea3d | 635 | if (written == size) { |
embeddedartists | 2:ddc1aa3bea3d | 636 | return t->read_us() - time; |
embeddedartists | 2:ddc1aa3bea3d | 637 | } else { |
embeddedartists | 2:ddc1aa3bea3d | 638 | DMBoard::instance().logger()->printf("Failed to write %s (only wrote %u of %u bytes). Aborting\n", fname, written, size); |
embeddedartists | 2:ddc1aa3bea3d | 639 | return 0; |
embeddedartists | 2:ddc1aa3bea3d | 640 | } |
embeddedartists | 2:ddc1aa3bea3d | 641 | } |
embeddedartists | 2:ddc1aa3bea3d | 642 | |
embeddedartists | 2:ddc1aa3bea3d | 643 | static void runWriteBenchmarks() { |
embeddedartists | 2:ddc1aa3bea3d | 644 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 2:ddc1aa3bea3d | 645 | uint32_t times[NUM_BENCHMARKS][3] = {0}; |
embeddedartists | 2:ddc1aa3bea3d | 646 | char buff[512]; |
embeddedartists | 2:ddc1aa3bea3d | 647 | Timer t; |
embeddedartists | 3:1716747cba16 | 648 | |
embeddedartists | 3:1716747cba16 | 649 | log->printf("Preparing to run WRITE tests...\n"); |
embeddedartists | 2:ddc1aa3bea3d | 650 | |
embeddedartists | 2:ddc1aa3bea3d | 651 | // For uSD cards it is not possible to read the data from QSPI flash. |
embeddedartists | 2:ddc1aa3bea3d | 652 | // To make all tests equal all source data is copied to external SDRAM |
embeddedartists | 2:ddc1aa3bea3d | 653 | // and from there to the destination file. Only the time from SDRAM to |
embeddedartists | 2:ddc1aa3bea3d | 654 | // file is meassured. |
embeddedartists | 2:ddc1aa3bea3d | 655 | uint8_t* dest = (uint8_t*)malloc(COPYBUF_SIZE); |
embeddedartists | 2:ddc1aa3bea3d | 656 | if (dest == NULL) { |
embeddedartists | 2:ddc1aa3bea3d | 657 | log->printf("Failed to allocate 10MBytes as buffer\n"); |
embeddedartists | 2:ddc1aa3bea3d | 658 | return; |
embeddedartists | 2:ddc1aa3bea3d | 659 | } |
embeddedartists | 2:ddc1aa3bea3d | 660 | |
embeddedartists | 2:ddc1aa3bea3d | 661 | // Clear the entire QSPI file system |
embeddedartists | 2:ddc1aa3bea3d | 662 | if (qspifs->format(QSPIFS_SIZE_MB) == 0) { |
embeddedartists | 2:ddc1aa3bea3d | 663 | log->printf("Formatting successful\n"); |
embeddedartists | 2:ddc1aa3bea3d | 664 | } else { |
embeddedartists | 2:ddc1aa3bea3d | 665 | log->printf("Failed to format QSPI file system!\n"); |
embeddedartists | 2:ddc1aa3bea3d | 666 | return; |
embeddedartists | 2:ddc1aa3bea3d | 667 | } |
embeddedartists | 2:ddc1aa3bea3d | 668 | |
embeddedartists | 2:ddc1aa3bea3d | 669 | // For uSD and USB formatting is a bad idea as the memory |
embeddedartists | 2:ddc1aa3bea3d | 670 | // might contain other important file. Just delete the files |
embeddedartists | 2:ddc1aa3bea3d | 671 | // we are using instead. |
embeddedartists | 2:ddc1aa3bea3d | 672 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 2:ddc1aa3bea3d | 673 | // MCI |
embeddedartists | 2:ddc1aa3bea3d | 674 | sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 2:ddc1aa3bea3d | 675 | remove(buff); |
embeddedartists | 2:ddc1aa3bea3d | 676 | |
embeddedartists | 2:ddc1aa3bea3d | 677 | //USB |
embeddedartists | 2:ddc1aa3bea3d | 678 | sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 2:ddc1aa3bea3d | 679 | remove(buff); |
embeddedartists | 2:ddc1aa3bea3d | 680 | } |
embeddedartists | 2:ddc1aa3bea3d | 681 | |
embeddedartists | 2:ddc1aa3bea3d | 682 | t.start(); |
embeddedartists | 2:ddc1aa3bea3d | 683 | |
embeddedartists | 2:ddc1aa3bea3d | 684 | // Do the benchmarking |
embeddedartists | 3:1716747cba16 | 685 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 686 | if (!BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 687 | // don't include the files for the image decoding in |
embeddedartists | 3:1716747cba16 | 688 | // the benchmark set |
embeddedartists | 3:1716747cba16 | 689 | continue; |
embeddedartists | 3:1716747cba16 | 690 | } |
embeddedartists | 3:1716747cba16 | 691 | |
embeddedartists | 2:ddc1aa3bea3d | 692 | // MCI |
embeddedartists | 2:ddc1aa3bea3d | 693 | sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 2:ddc1aa3bea3d | 694 | memset(dest, 0, COPYBUF_SIZE); |
embeddedartists | 2:ddc1aa3bea3d | 695 | times[i][0] = writeFile(buff, i, &t, dest); |
embeddedartists | 3:1716747cba16 | 696 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][0]); |
embeddedartists | 2:ddc1aa3bea3d | 697 | |
embeddedartists | 2:ddc1aa3bea3d | 698 | //USB |
embeddedartists | 2:ddc1aa3bea3d | 699 | sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 2:ddc1aa3bea3d | 700 | memset(dest, 0, COPYBUF_SIZE); |
embeddedartists | 2:ddc1aa3bea3d | 701 | times[i][1] = writeFile(buff, i, &t, dest); |
embeddedartists | 3:1716747cba16 | 702 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][1]); |
embeddedartists | 2:ddc1aa3bea3d | 703 | |
embeddedartists | 2:ddc1aa3bea3d | 704 | //QSPIFS |
embeddedartists | 2:ddc1aa3bea3d | 705 | sprintf(buff, "/qspi/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 2:ddc1aa3bea3d | 706 | memset(dest, 0, COPYBUF_SIZE); |
embeddedartists | 2:ddc1aa3bea3d | 707 | times[i][2] = writeFile(buff, i, &t, dest); |
embeddedartists | 3:1716747cba16 | 708 | log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][2]); |
embeddedartists | 2:ddc1aa3bea3d | 709 | } |
embeddedartists | 2:ddc1aa3bea3d | 710 | |
embeddedartists | 2:ddc1aa3bea3d | 711 | log->printf("\n\n----\nSummary:\n"); |
embeddedartists | 2:ddc1aa3bea3d | 712 | |
embeddedartists | 2:ddc1aa3bea3d | 713 | log->printf("\n File Information\n"); |
embeddedartists | 3:1716747cba16 | 714 | log->printf("%20s %10s\n", "Filename", "Size"); |
embeddedartists | 3:1716747cba16 | 715 | log->printf("%20s %10s\n", "--------", "----"); |
embeddedartists | 2:ddc1aa3bea3d | 716 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 717 | if (BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 718 | log->printf("%20s %10d bytes\n", BENCHMARK_INPUT[i].fname, BENCHMARK_INPUT[i].size); |
embeddedartists | 3:1716747cba16 | 719 | } |
embeddedartists | 2:ddc1aa3bea3d | 720 | } |
embeddedartists | 2:ddc1aa3bea3d | 721 | |
embeddedartists | 2:ddc1aa3bea3d | 722 | log->printf("\n Write times (in us)\n"); |
embeddedartists | 3:1716747cba16 | 723 | log->printf("%20s %10s %10s %10s\n", "Filename", "uSD Card", "USB", "QSPI FS"); |
embeddedartists | 3:1716747cba16 | 724 | log->printf("%20s %10s %10s %10s\n", "--------", "--------", "---", "-------"); |
embeddedartists | 3:1716747cba16 | 725 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 726 | if (BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 727 | char* p = (char*)dest; |
embeddedartists | 3:1716747cba16 | 728 | for (int x = 0; x < 3; x++) { |
embeddedartists | 3:1716747cba16 | 729 | if (times[i][x] == 0) { |
embeddedartists | 3:1716747cba16 | 730 | p += sprintf(p, "%10s ", "N/A"); |
embeddedartists | 3:1716747cba16 | 731 | } else { |
embeddedartists | 3:1716747cba16 | 732 | p += sprintf(p, "%10d ", times[i][x]); |
embeddedartists | 3:1716747cba16 | 733 | } |
embeddedartists | 3:1716747cba16 | 734 | } |
embeddedartists | 3:1716747cba16 | 735 | log->printf("%20s %s\n", BENCHMARK_INPUT[i].fname, dest); |
embeddedartists | 3:1716747cba16 | 736 | } |
embeddedartists | 3:1716747cba16 | 737 | } |
embeddedartists | 3:1716747cba16 | 738 | |
embeddedartists | 3:1716747cba16 | 739 | log->printf("\n Write speeds\n"); |
embeddedartists | 3:1716747cba16 | 740 | log->printf("%20s %-12s %-12s %-12s\n", "Filename", "uSD Card", "USB", "QSPI FS"); |
embeddedartists | 3:1716747cba16 | 741 | log->printf("%20s %s %s %s\n", "--------", "------------", "------------", "------------"); |
embeddedartists | 3:1716747cba16 | 742 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 743 | if (BENCHMARK_INPUT[i].rw) { |
embeddedartists | 3:1716747cba16 | 744 | char* p = (char*)dest; |
embeddedartists | 3:1716747cba16 | 745 | for (int x = 0; x < 3; x++) { |
embeddedartists | 3:1716747cba16 | 746 | if (times[i][x] == 0) { |
embeddedartists | 3:1716747cba16 | 747 | p += sprintf(p, "%12s ", "N/A "); |
embeddedartists | 3:1716747cba16 | 748 | } else { |
embeddedartists | 3:1716747cba16 | 749 | double t = times[i][x]; |
embeddedartists | 3:1716747cba16 | 750 | double s = BENCHMARK_INPUT[i].size; |
embeddedartists | 3:1716747cba16 | 751 | double v = (s*1000000)/t; |
embeddedartists | 3:1716747cba16 | 752 | if (v < 10000) { |
embeddedartists | 3:1716747cba16 | 753 | p += sprintf(p, "%#7.2F b/s ", v); |
embeddedartists | 3:1716747cba16 | 754 | } else if (v < 10000000) { |
embeddedartists | 3:1716747cba16 | 755 | p += sprintf(p, "%#7.2F Kb/s ", v/1024.0); |
embeddedartists | 3:1716747cba16 | 756 | } else { |
embeddedartists | 3:1716747cba16 | 757 | p += sprintf(p, "%#7.2F Mb/s ", v/(1024.0*1024.0)); |
embeddedartists | 3:1716747cba16 | 758 | } |
embeddedartists | 3:1716747cba16 | 759 | } |
embeddedartists | 3:1716747cba16 | 760 | } |
embeddedartists | 3:1716747cba16 | 761 | log->printf("%20s %s \n", BENCHMARK_INPUT[i].fname, dest); |
embeddedartists | 3:1716747cba16 | 762 | } |
embeddedartists | 3:1716747cba16 | 763 | } |
embeddedartists | 3:1716747cba16 | 764 | |
embeddedartists | 3:1716747cba16 | 765 | log->printf("\n\n---\n"); |
embeddedartists | 3:1716747cba16 | 766 | |
embeddedartists | 3:1716747cba16 | 767 | free(dest); |
embeddedartists | 3:1716747cba16 | 768 | } |
embeddedartists | 3:1716747cba16 | 769 | |
embeddedartists | 3:1716747cba16 | 770 | static void runImageBenchmarks() { |
embeddedartists | 3:1716747cba16 | 771 | RtosLog* log = DMBoard::instance().logger(); |
embeddedartists | 3:1716747cba16 | 772 | uint32_t times[NUM_BENCHMARKS][5] = {0}; |
embeddedartists | 3:1716747cba16 | 773 | uint32_t tmp; |
embeddedartists | 3:1716747cba16 | 774 | char buff[512]; |
embeddedartists | 3:1716747cba16 | 775 | int result; |
embeddedartists | 3:1716747cba16 | 776 | Image::ImageData_t imgData; |
embeddedartists | 3:1716747cba16 | 777 | Timer t; |
embeddedartists | 3:1716747cba16 | 778 | |
embeddedartists | 3:1716747cba16 | 779 | t.start(); |
embeddedartists | 3:1716747cba16 | 780 | |
embeddedartists | 2:ddc1aa3bea3d | 781 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 782 | |
embeddedartists | 3:1716747cba16 | 783 | // MCI |
embeddedartists | 3:1716747cba16 | 784 | sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 3:1716747cba16 | 785 | tmp = t.read_us(); |
embeddedartists | 3:1716747cba16 | 786 | result = Image::decode(buff, Image::RES_16BIT, &imgData); |
embeddedartists | 3:1716747cba16 | 787 | times[i][0] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 788 | if (result == 0) { |
embeddedartists | 3:1716747cba16 | 789 | log->printf("Decoding %-30s took %8uus\n", buff, times[i][0]); |
embeddedartists | 3:1716747cba16 | 790 | if (imgData.pointerToFree != NULL) { |
embeddedartists | 3:1716747cba16 | 791 | free(imgData.pointerToFree); |
embeddedartists | 3:1716747cba16 | 792 | imgData.pointerToFree = NULL; |
embeddedartists | 3:1716747cba16 | 793 | } |
embeddedartists | 3:1716747cba16 | 794 | } else { |
embeddedartists | 3:1716747cba16 | 795 | log->printf("Decoding %-30s failed\n", buff); |
embeddedartists | 3:1716747cba16 | 796 | times[i][0] = 0; |
embeddedartists | 3:1716747cba16 | 797 | } |
embeddedartists | 3:1716747cba16 | 798 | |
embeddedartists | 3:1716747cba16 | 799 | //USB |
embeddedartists | 3:1716747cba16 | 800 | sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 3:1716747cba16 | 801 | tmp = t.read_us(); |
embeddedartists | 3:1716747cba16 | 802 | result = Image::decode(buff, Image::RES_16BIT, &imgData); |
embeddedartists | 3:1716747cba16 | 803 | times[i][1] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 804 | if (result == 0) { |
embeddedartists | 3:1716747cba16 | 805 | log->printf("Decoding %-30s took %8uus\n", buff, times[i][1]); |
embeddedartists | 3:1716747cba16 | 806 | if (imgData.pointerToFree != NULL) { |
embeddedartists | 3:1716747cba16 | 807 | free(imgData.pointerToFree); |
embeddedartists | 3:1716747cba16 | 808 | imgData.pointerToFree = NULL; |
embeddedartists | 3:1716747cba16 | 809 | } |
embeddedartists | 3:1716747cba16 | 810 | } else { |
embeddedartists | 3:1716747cba16 | 811 | log->printf("Decoding %-30s failed\n", buff); |
embeddedartists | 3:1716747cba16 | 812 | times[i][1] = 0; |
embeddedartists | 3:1716747cba16 | 813 | } |
embeddedartists | 3:1716747cba16 | 814 | |
embeddedartists | 3:1716747cba16 | 815 | //QSPIFS |
embeddedartists | 3:1716747cba16 | 816 | sprintf(buff, "/qspi/%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 3:1716747cba16 | 817 | tmp = t.read_us(); |
embeddedartists | 3:1716747cba16 | 818 | result = Image::decode(buff, Image::RES_16BIT, &imgData); |
embeddedartists | 3:1716747cba16 | 819 | times[i][2] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 820 | if (result == 0) { |
embeddedartists | 3:1716747cba16 | 821 | log->printf("Decoding %-30s took %8uus\n", buff, times[i][2]); |
embeddedartists | 3:1716747cba16 | 822 | if (imgData.pointerToFree != NULL) { |
embeddedartists | 3:1716747cba16 | 823 | free(imgData.pointerToFree); |
embeddedartists | 3:1716747cba16 | 824 | imgData.pointerToFree = NULL; |
embeddedartists | 3:1716747cba16 | 825 | } |
embeddedartists | 3:1716747cba16 | 826 | } else { |
embeddedartists | 3:1716747cba16 | 827 | log->printf("Decoding %-30s failed\n", buff); |
embeddedartists | 3:1716747cba16 | 828 | times[i][2] = 0; |
embeddedartists | 3:1716747cba16 | 829 | } |
embeddedartists | 3:1716747cba16 | 830 | |
embeddedartists | 3:1716747cba16 | 831 | //IFLASH |
embeddedartists | 3:1716747cba16 | 832 | sprintf(buff, "IFLASH /%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 3:1716747cba16 | 833 | if (BENCHMARK_INPUT[i].iflash_direct != NULL) { |
embeddedartists | 3:1716747cba16 | 834 | tmp = t.read_us(); |
embeddedartists | 3:1716747cba16 | 835 | result = Image::decode(BENCHMARK_INPUT[i].iflash_direct, BENCHMARK_INPUT[i].size, Image::RES_16BIT, &imgData); |
embeddedartists | 3:1716747cba16 | 836 | times[i][3] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 837 | if (result == 0) { |
embeddedartists | 3:1716747cba16 | 838 | log->printf("Decoding %-30s took %8uus\n", buff, times[i][3]); |
embeddedartists | 3:1716747cba16 | 839 | if (imgData.pointerToFree != NULL) { |
embeddedartists | 3:1716747cba16 | 840 | free(imgData.pointerToFree); |
embeddedartists | 3:1716747cba16 | 841 | imgData.pointerToFree = NULL; |
embeddedartists | 3:1716747cba16 | 842 | } |
embeddedartists | 3:1716747cba16 | 843 | } else { |
embeddedartists | 3:1716747cba16 | 844 | log->printf("Decoding %-30s failed\n", buff); |
embeddedartists | 3:1716747cba16 | 845 | times[i][3] = 0; |
embeddedartists | 3:1716747cba16 | 846 | } |
embeddedartists | 3:1716747cba16 | 847 | } else { |
embeddedartists | 3:1716747cba16 | 848 | log->printf("Decoding %-30s skipped\n", buff); |
embeddedartists | 3:1716747cba16 | 849 | } |
embeddedartists | 3:1716747cba16 | 850 | |
embeddedartists | 3:1716747cba16 | 851 | //QSPI |
embeddedartists | 3:1716747cba16 | 852 | sprintf(buff, "QSPI /%s", BENCHMARK_INPUT[i].fname); |
embeddedartists | 3:1716747cba16 | 853 | if (BENCHMARK_INPUT[i].qspi_direct != NULL) { |
embeddedartists | 3:1716747cba16 | 854 | tmp = t.read_us(); |
embeddedartists | 3:1716747cba16 | 855 | result = Image::decode(BENCHMARK_INPUT[i].qspi_direct, BENCHMARK_INPUT[i].size, Image::RES_16BIT, &imgData); |
embeddedartists | 3:1716747cba16 | 856 | times[i][4] = t.read_us() - tmp; |
embeddedartists | 3:1716747cba16 | 857 | if (result == 0) { |
embeddedartists | 3:1716747cba16 | 858 | log->printf("Decoding %-30s took %8uus\n", buff, times[i][4]); |
embeddedartists | 3:1716747cba16 | 859 | if (imgData.pointerToFree != NULL) { |
embeddedartists | 3:1716747cba16 | 860 | free(imgData.pointerToFree); |
embeddedartists | 3:1716747cba16 | 861 | imgData.pointerToFree = NULL; |
embeddedartists | 3:1716747cba16 | 862 | } |
embeddedartists | 3:1716747cba16 | 863 | } else { |
embeddedartists | 3:1716747cba16 | 864 | log->printf("Decoding %-30s failed\n", buff); |
embeddedartists | 3:1716747cba16 | 865 | times[i][4] = 0; |
embeddedartists | 3:1716747cba16 | 866 | } |
embeddedartists | 3:1716747cba16 | 867 | } else { |
embeddedartists | 3:1716747cba16 | 868 | log->printf("Decoding %-30s skipped\n", buff); |
embeddedartists | 3:1716747cba16 | 869 | } |
embeddedartists | 3:1716747cba16 | 870 | } |
embeddedartists | 3:1716747cba16 | 871 | |
embeddedartists | 3:1716747cba16 | 872 | log->printf("\n\n----\nSummary:\n"); |
embeddedartists | 3:1716747cba16 | 873 | |
embeddedartists | 3:1716747cba16 | 874 | log->printf("\n File Information\n"); |
embeddedartists | 3:1716747cba16 | 875 | log->printf("%20s %10s\n", "Filename", "Size"); |
embeddedartists | 3:1716747cba16 | 876 | log->printf("%20s %10s\n", "--------", "----"); |
embeddedartists | 3:1716747cba16 | 877 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 878 | log->printf("%20s %10d bytes\n", BENCHMARK_INPUT[i].fname, BENCHMARK_INPUT[i].size); |
embeddedartists | 3:1716747cba16 | 879 | } |
embeddedartists | 3:1716747cba16 | 880 | |
embeddedartists | 3:1716747cba16 | 881 | log->printf("\n Decode times (in us)\n"); |
embeddedartists | 3:1716747cba16 | 882 | log->printf("%20s %10s %10s %10s %10s %10s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]"); |
embeddedartists | 3:1716747cba16 | 883 | log->printf("%20s %10s %10s %10s %10s %10s\n", "--------", "--------", "---", "-------", "--------", "------"); |
embeddedartists | 3:1716747cba16 | 884 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 885 | char* p = (char*)buff; |
embeddedartists | 3:1716747cba16 | 886 | for (int x = 0; x < 5; x++) { |
embeddedartists | 2:ddc1aa3bea3d | 887 | if (times[i][x] == 0) { |
embeddedartists | 2:ddc1aa3bea3d | 888 | p += sprintf(p, "%10s ", "N/A"); |
embeddedartists | 2:ddc1aa3bea3d | 889 | } else { |
embeddedartists | 2:ddc1aa3bea3d | 890 | p += sprintf(p, "%10d ", times[i][x]); |
embeddedartists | 2:ddc1aa3bea3d | 891 | } |
embeddedartists | 2:ddc1aa3bea3d | 892 | } |
embeddedartists | 3:1716747cba16 | 893 | log->printf("%20s %s\n", BENCHMARK_INPUT[i].fname, buff); |
embeddedartists | 2:ddc1aa3bea3d | 894 | } |
embeddedartists | 2:ddc1aa3bea3d | 895 | |
embeddedartists | 3:1716747cba16 | 896 | log->printf("\n Decode speeds\n"); |
embeddedartists | 3:1716747cba16 | 897 | log->printf("%20s %-12s %-12s %-12s %-12s %-12s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]"); |
embeddedartists | 3:1716747cba16 | 898 | log->printf("%20s %s %s %s %s %s\n", "--------", "------------", "------------", "------------", "------------", "------------"); |
embeddedartists | 2:ddc1aa3bea3d | 899 | for (int i = 0; i < NUM_BENCHMARKS; i++) { |
embeddedartists | 3:1716747cba16 | 900 | char* p = (char*)buff; |
embeddedartists | 3:1716747cba16 | 901 | for (int x = 0; x < 5; x++) { |
embeddedartists | 2:ddc1aa3bea3d | 902 | if (times[i][x] == 0) { |
embeddedartists | 2:ddc1aa3bea3d | 903 | p += sprintf(p, "%12s ", "N/A "); |
embeddedartists | 2:ddc1aa3bea3d | 904 | } else { |
embeddedartists | 2:ddc1aa3bea3d | 905 | double t = times[i][x]; |
embeddedartists | 2:ddc1aa3bea3d | 906 | double s = BENCHMARK_INPUT[i].size; |
embeddedartists | 2:ddc1aa3bea3d | 907 | double v = (s*1000000)/t; |
embeddedartists | 2:ddc1aa3bea3d | 908 | if (v < 10000) { |
embeddedartists | 2:ddc1aa3bea3d | 909 | p += sprintf(p, "%#7.2F b/s ", v); |
embeddedartists | 2:ddc1aa3bea3d | 910 | } else if (v < 10000000) { |
embeddedartists | 2:ddc1aa3bea3d | 911 | p += sprintf(p, "%#7.2F Kb/s ", v/1024.0); |
embeddedartists | 2:ddc1aa3bea3d | 912 | } else { |
embeddedartists | 2:ddc1aa3bea3d | 913 | p += sprintf(p, "%#7.2F Mb/s ", v/(1024.0*1024.0)); |
embeddedartists | 2:ddc1aa3bea3d | 914 | } |
embeddedartists | 2:ddc1aa3bea3d | 915 | } |
embeddedartists | 2:ddc1aa3bea3d | 916 | } |
embeddedartists | 3:1716747cba16 | 917 | log->printf("%20s %s \n", BENCHMARK_INPUT[i].fname, buff); |
embeddedartists | 2:ddc1aa3bea3d | 918 | } |
embeddedartists | 2:ddc1aa3bea3d | 919 | |
embeddedartists | 2:ddc1aa3bea3d | 920 | log->printf("\n\n---\n"); |
alindvall | 0:b77503796c51 | 921 | } |
alindvall | 0:b77503796c51 | 922 | |
alindvall | 0:b77503796c51 | 923 | /****************************************************************************** |
alindvall | 0:b77503796c51 | 924 | * Main |
alindvall | 0:b77503796c51 | 925 | *****************************************************************************/ |
alindvall | 0:b77503796c51 | 926 | |
alindvall | 0:b77503796c51 | 927 | int main() |
alindvall | 0:b77503796c51 | 928 | { |
alindvall | 0:b77503796c51 | 929 | DMBoard::BoardError err; |
alindvall | 0:b77503796c51 | 930 | DMBoard* board = &DMBoard::instance(); |
alindvall | 0:b77503796c51 | 931 | RtosLog* log = board->logger(); |
alindvall | 0:b77503796c51 | 932 | |
alindvall | 0:b77503796c51 | 933 | do { |
alindvall | 0:b77503796c51 | 934 | err = board->init(); |
alindvall | 0:b77503796c51 | 935 | if (err != DMBoard::Ok) { |
alindvall | 0:b77503796c51 | 936 | log->printf("Failed to initialize the board, got error %d\r\n", err); |
alindvall | 0:b77503796c51 | 937 | break; |
alindvall | 0:b77503796c51 | 938 | } |
alindvall | 0:b77503796c51 | 939 | |
alindvall | 0:b77503796c51 | 940 | log->printf("\n\nBenchmarking. (Built "__DATE__" at "__TIME__")\n\n"); |
alindvall | 0:b77503796c51 | 941 | |
alindvall | 0:b77503796c51 | 942 | log->printf("Preparing file systems for benchmarking\n"); |
alindvall | 0:b77503796c51 | 943 | if (!prepare()) { |
alindvall | 0:b77503796c51 | 944 | log->printf("Failed to prepare for benchmarking\r\n"); |
alindvall | 0:b77503796c51 | 945 | break; |
alindvall | 0:b77503796c51 | 946 | } |
alindvall | 0:b77503796c51 | 947 | |
embeddedartists | 2:ddc1aa3bea3d | 948 | runReadBenchmarks(); |
embeddedartists | 3:1716747cba16 | 949 | runImageBenchmarks(); |
embeddedartists | 2:ddc1aa3bea3d | 950 | |
embeddedartists | 2:ddc1aa3bea3d | 951 | Thread::wait(1000); |
embeddedartists | 2:ddc1aa3bea3d | 952 | log->printf("Press the USER button to run WRITE tests!\n"); |
embeddedartists | 2:ddc1aa3bea3d | 953 | while(!board->buttonPressed()) { |
embeddedartists | 2:ddc1aa3bea3d | 954 | Thread::wait(20); |
embeddedartists | 2:ddc1aa3bea3d | 955 | } |
embeddedartists | 2:ddc1aa3bea3d | 956 | while(board->buttonPressed()) { |
embeddedartists | 2:ddc1aa3bea3d | 957 | Thread::wait(20); |
embeddedartists | 2:ddc1aa3bea3d | 958 | } |
embeddedartists | 2:ddc1aa3bea3d | 959 | |
embeddedartists | 2:ddc1aa3bea3d | 960 | runWriteBenchmarks(); |
alindvall | 0:b77503796c51 | 961 | |
alindvall | 0:b77503796c51 | 962 | } while(false); |
alindvall | 0:b77503796c51 | 963 | |
alindvall | 0:b77503796c51 | 964 | if (err != DMBoard::Ok) { |
alindvall | 0:b77503796c51 | 965 | log->printf("\nTERMINATING\n"); |
alindvall | 0:b77503796c51 | 966 | } |
alindvall | 0:b77503796c51 | 967 | |
alindvall | 0:b77503796c51 | 968 | while(true) { |
alindvall | 0:b77503796c51 | 969 | Thread::wait(1000); |
alindvall | 0:b77503796c51 | 970 | } |
alindvall | 0:b77503796c51 | 971 | } |
alindvall | 0:b77503796c51 | 972 |