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.

Committer:
embeddedartists
Date:
Tue Nov 05 06:44:07 2019 +0000
Revision:
6:47b4bed9fa13
Parent:
5:788710a95951
Updates related to mbed OS 5

Who changed what in which revision?

UserRevisionLine numberNew 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;
embeddedartists 6:47b4bed9fa13 267 static FATFileSystem* mciFatFs;
alindvall 0:b77503796c51 268 static QSPIFileSystem* qspifs;
alindvall 0:b77503796c51 269 static USBHostMSD* usbmsd;
alindvall 0:b77503796c51 270
alindvall 0:b77503796c51 271 /******************************************************************************
alindvall 0:b77503796c51 272 * Private Functions
alindvall 0:b77503796c51 273 *****************************************************************************/
alindvall 0:b77503796c51 274
alindvall 0:b77503796c51 275
alindvall 0:b77503796c51 276 static bool fileExists(const char* fname) {
alindvall 0:b77503796c51 277 FILE* f = fopen(fname, "r");
alindvall 0:b77503796c51 278 if (f != NULL) {
alindvall 0:b77503796c51 279 fclose(f);
alindvall 0:b77503796c51 280 return true;
alindvall 0:b77503796c51 281 }
alindvall 0:b77503796c51 282 return false;
alindvall 0:b77503796c51 283 }
alindvall 0:b77503796c51 284
alindvall 0:b77503796c51 285 static bool haveAllFiles(const char* prefix) {
alindvall 0:b77503796c51 286 char buff[512] = {0};
alindvall 0:b77503796c51 287 strcpy(buff, prefix);
alindvall 0:b77503796c51 288 int len = strlen(buff);
alindvall 0:b77503796c51 289
alindvall 0:b77503796c51 290 for (int i = 0; i < NUM_BENCHMARKS; i++) {
alindvall 0:b77503796c51 291 strcpy(buff+len, BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 292 if (!fileExists(buff)) {
alindvall 0:b77503796c51 293 DMBoard::instance().logger()->printf("File %s is missing\n", buff);
alindvall 0:b77503796c51 294 return false;
alindvall 0:b77503796c51 295 }
alindvall 0:b77503796c51 296 }
alindvall 0:b77503796c51 297 return true;
alindvall 0:b77503796c51 298 }
alindvall 0:b77503796c51 299
alindvall 5:788710a95951 300 static uint32_t writeInChunks(FILE* f, const uint8_t* src, uint32_t len, bool destIsMCI)
alindvall 5:788710a95951 301 {
alindvall 5:788710a95951 302 if (destIsMCI) {
alindvall 5:788710a95951 303 uint32_t left = len;
alindvall 5:788710a95951 304 uint32_t written = 0;
alindvall 5:788710a95951 305 uint32_t chunk;
alindvall 5:788710a95951 306 while (left > 0) {
alindvall 5:788710a95951 307 // MCI File system only supports writing 512 bytes at a time
alindvall 5:788710a95951 308 chunk = ((left < 512) ? left : 512);
alindvall 5:788710a95951 309 uint32_t tmp = fwrite(src+written, 1, chunk, f);
alindvall 5:788710a95951 310 if (tmp != chunk) {
alindvall 5:788710a95951 311 // failed, return what we have written so far
alindvall 5:788710a95951 312 return written;
alindvall 5:788710a95951 313 }
alindvall 5:788710a95951 314 left -= chunk;
alindvall 5:788710a95951 315 written += chunk;
alindvall 5:788710a95951 316 }
alindvall 5:788710a95951 317 return written;
alindvall 5:788710a95951 318 } else {
alindvall 5:788710a95951 319 // All file systems except for MCI supports complete fwrites and will split it into
alindvall 5:788710a95951 320 // chunks (if needed) internally.
alindvall 5:788710a95951 321 return fwrite(src, 1, len, f);
alindvall 5:788710a95951 322 }
alindvall 5:788710a95951 323 }
alindvall 5:788710a95951 324
alindvall 0:b77503796c51 325 static bool createFiles(const char* prefix) {
alindvall 0:b77503796c51 326 RtosLog* log = DMBoard::instance().logger();
alindvall 0:b77503796c51 327 char buff[512] = {0};
alindvall 0:b77503796c51 328 strcpy(buff, prefix);
alindvall 0:b77503796c51 329 int len = strlen(buff);
alindvall 0:b77503796c51 330
alindvall 0:b77503796c51 331 for (int i = 0; i < NUM_BENCHMARKS; i++) {
alindvall 0:b77503796c51 332 strcpy(buff+len, BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 333 log->printf(" writing %u bytes to %s\n", BENCHMARK_INPUT[i].size, buff);
alindvall 0:b77503796c51 334 FILE* f = fopen(buff, "w");
alindvall 0:b77503796c51 335 if (f == NULL) {
alindvall 0:b77503796c51 336 log->printf("Failed to create file %s - ABORTING\n", buff);
alindvall 0:b77503796c51 337 return false;
alindvall 0:b77503796c51 338 }
alindvall 0:b77503796c51 339 uint32_t written;
alindvall 0:b77503796c51 340 if (BENCHMARK_INPUT[i].iflash_direct == NULL) {
alindvall 5:788710a95951 341 written = writeInChunks(f, BENCHMARK_INPUT[i].qspi_direct, BENCHMARK_INPUT[i].size, (prefix[1]=='m'));
alindvall 0:b77503796c51 342 } else {
alindvall 5:788710a95951 343 written = writeInChunks(f, BENCHMARK_INPUT[i].iflash_direct, BENCHMARK_INPUT[i].size, (prefix[1]=='m'));
alindvall 0:b77503796c51 344 }
alindvall 0:b77503796c51 345 if (written != BENCHMARK_INPUT[i].size) {
alindvall 0:b77503796c51 346 log->printf("Failed to write %u (only wrote %u) bytes to %s - ABORTING\n", BENCHMARK_INPUT[i].size, written, buff);
embeddedartists 2:ddc1aa3bea3d 347 fclose(f);
alindvall 0:b77503796c51 348 return false;
alindvall 0:b77503796c51 349 }
alindvall 0:b77503796c51 350 fclose(f);
alindvall 0:b77503796c51 351 }
alindvall 0:b77503796c51 352 return true;
alindvall 0:b77503796c51 353 }
alindvall 0:b77503796c51 354
alindvall 0:b77503796c51 355 static bool prepareMCI() {
alindvall 0:b77503796c51 356 RtosLog* log = DMBoard::instance().logger();
alindvall 0:b77503796c51 357 bool ok = false;
alindvall 0:b77503796c51 358
embeddedartists 6:47b4bed9fa13 359 mcifs = new MCIFileSystem(P4_16);
embeddedartists 6:47b4bed9fa13 360 mciFatFs = new FATFileSystem("mci");
embeddedartists 6:47b4bed9fa13 361 mciFatFs->mount(mcifs);
alindvall 0:b77503796c51 362
alindvall 0:b77503796c51 363 if (mcifs->cardInserted()) {
alindvall 0:b77503796c51 364 log->printf("uSD card detected\n");
alindvall 0:b77503796c51 365
alindvall 0:b77503796c51 366 if (haveAllFiles("/mci/")) {
alindvall 0:b77503796c51 367 log->printf("uSD file system prepared!\n");
alindvall 0:b77503796c51 368 ok = true;
alindvall 0:b77503796c51 369 } else {
alindvall 0:b77503796c51 370 log->printf("One or more files missing, need to (re-)prepare the uSD file system\n");
alindvall 0:b77503796c51 371
alindvall 0:b77503796c51 372 log->printf("Preparing uSD file system...\n");
alindvall 0:b77503796c51 373 if (createFiles("/mci/")) {
alindvall 0:b77503796c51 374 log->printf("uSD file system prepared!\n");
alindvall 0:b77503796c51 375 ok = true;
alindvall 0:b77503796c51 376 } else {
alindvall 0:b77503796c51 377 log->printf("Failed to prepare uSD file system!\n");
alindvall 0:b77503796c51 378 }
alindvall 0:b77503796c51 379 }
alindvall 0:b77503796c51 380 } else {
alindvall 0:b77503796c51 381 log->printf("No uSD card detected. Insert one and reset\n");
alindvall 0:b77503796c51 382 }
alindvall 0:b77503796c51 383
alindvall 0:b77503796c51 384 return ok;
alindvall 0:b77503796c51 385 }
alindvall 0:b77503796c51 386
alindvall 0:b77503796c51 387 static bool prepareUSB() {
alindvall 0:b77503796c51 388 RtosLog* log = DMBoard::instance().logger();
alindvall 0:b77503796c51 389 bool ok = false;
alindvall 0:b77503796c51 390
alindvall 0:b77503796c51 391 usbmsd = new USBHostMSD("usb");
alindvall 0:b77503796c51 392 USBHost* host = USBHost::getHostInst();
embeddedartists 6:47b4bed9fa13 393 EventFlags connectionEvent;
embeddedartists 6:47b4bed9fa13 394 host->signalOnConnections(&connectionEvent, USBH_CONNECTION_EVENT);
alindvall 0:b77503796c51 395
alindvall 0:b77503796c51 396 log->printf("waiting for connect/disconnect message from USBHost...\n");
embeddedartists 6:47b4bed9fa13 397 connectionEvent.wait_any(USBH_CONNECTION_EVENT);
alindvall 0:b77503796c51 398
alindvall 0:b77503796c51 399 if (usbmsd->connect()) {
alindvall 0:b77503796c51 400 log->printf("USB MemoryStick detected\n");
alindvall 0:b77503796c51 401
alindvall 0:b77503796c51 402 if (haveAllFiles("/usb/")) {
alindvall 0:b77503796c51 403 log->printf("USB MemoryStick file system prepared!\n");
alindvall 0:b77503796c51 404 ok = true;
alindvall 0:b77503796c51 405 } else {
alindvall 0:b77503796c51 406 log->printf("One or more files missing, need to (re-)prepare the USB MemoryStick\n");
alindvall 0:b77503796c51 407
alindvall 0:b77503796c51 408 log->printf("Preparing USB MemoryStick file system...\n");
alindvall 0:b77503796c51 409 if (createFiles("/usb/")) {
alindvall 0:b77503796c51 410 log->printf("USB MemoryStick file system prepared!\n");
alindvall 0:b77503796c51 411 ok = true;
alindvall 0:b77503796c51 412 } else {
alindvall 0:b77503796c51 413 log->printf("Failed to prepare USB MemoryStick file system!\n");
alindvall 0:b77503796c51 414 }
alindvall 0:b77503796c51 415 }
alindvall 0:b77503796c51 416 } else {
alindvall 0:b77503796c51 417 log->printf("No USB MemoryStick detected. Insert one and reset\n");
alindvall 0:b77503796c51 418 }
alindvall 0:b77503796c51 419
alindvall 0:b77503796c51 420 return ok;
alindvall 0:b77503796c51 421 }
alindvall 0:b77503796c51 422
alindvall 0:b77503796c51 423 static bool prepareQSPIFS() {
alindvall 0:b77503796c51 424 RtosLog* log = DMBoard::instance().logger();
alindvall 0:b77503796c51 425 bool ok = false;
alindvall 0:b77503796c51 426 bool format = false;
alindvall 0:b77503796c51 427
alindvall 0:b77503796c51 428 qspifs = new QSPIFileSystem("qspi");
alindvall 0:b77503796c51 429
alindvall 0:b77503796c51 430 do {
alindvall 0:b77503796c51 431 if (qspifs->isformatted()) {
alindvall 0:b77503796c51 432 uint32_t start, end;
alindvall 5:788710a95951 433 log->printf("QSPI file system detected\n");
alindvall 0:b77503796c51 434 qspifs->getMemoryBoundaries(&start, &end);
alindvall 0:b77503796c51 435 if ((end-start) >= QSPIFS_SIZE) {
alindvall 0:b77503796c51 436 if (haveAllFiles("/qspi/")) {
alindvall 0:b77503796c51 437 log->printf("QSPI file system prepared!\n");
alindvall 0:b77503796c51 438 ok = true;
alindvall 0:b77503796c51 439 break;
alindvall 0:b77503796c51 440 } else {
alindvall 0:b77503796c51 441 log->printf("One or more files missing, need to (re-)prepare the QSPI file system\n");
embeddedartists 3:1716747cba16 442 format = true;
alindvall 0:b77503796c51 443 }
alindvall 0:b77503796c51 444 } else {
alindvall 0:b77503796c51 445 log->printf("Found too small file system (only %dMB). Formatting...\n", (end-start)/(1024*1024));
alindvall 0:b77503796c51 446 format = true;
alindvall 0:b77503796c51 447 }
alindvall 0:b77503796c51 448 } else {
alindvall 0:b77503796c51 449 log->printf("No QSPI file system detected. Formatting...\n");
alindvall 0:b77503796c51 450 format = true;
alindvall 0:b77503796c51 451 }
alindvall 0:b77503796c51 452
alindvall 0:b77503796c51 453 if (format) {
alindvall 0:b77503796c51 454 if (qspifs->format(QSPIFS_SIZE_MB) == 0) {
alindvall 0:b77503796c51 455 log->printf("Formatting successful\n");
alindvall 0:b77503796c51 456 } else {
alindvall 0:b77503796c51 457 log->printf("Failed to format QSPI file system!\n");
alindvall 0:b77503796c51 458 break;
alindvall 0:b77503796c51 459 }
alindvall 0:b77503796c51 460 }
alindvall 0:b77503796c51 461
alindvall 0:b77503796c51 462 log->printf("Preparing QSPI file system...\n");
alindvall 0:b77503796c51 463 if (createFiles("/qspi/")) {
alindvall 0:b77503796c51 464 log->printf("QSPI file system prepared!\n");
alindvall 0:b77503796c51 465 ok = true;
alindvall 0:b77503796c51 466 } else {
alindvall 0:b77503796c51 467 log->printf("Failed to prepare QSPI file system!\n");
alindvall 0:b77503796c51 468 }
alindvall 0:b77503796c51 469 } while(false);
alindvall 0:b77503796c51 470
alindvall 0:b77503796c51 471 return ok;
alindvall 0:b77503796c51 472 }
alindvall 0:b77503796c51 473
alindvall 0:b77503796c51 474 static bool prepare() {
embeddedartists 1:b000ac168e46 475 RtosLog* log = DMBoard::instance().logger();
embeddedartists 1:b000ac168e46 476
embeddedartists 1:b000ac168e46 477 // make sure that the linker actually placed the data in the
embeddedartists 1:b000ac168e46 478 // correct flashes
embeddedartists 1:b000ac168e46 479 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 1:b000ac168e46 480 if (BENCHMARK_INPUT[i].iflash_direct != NULL) {
embeddedartists 1:b000ac168e46 481 uint32_t tmp = (uint32_t)BENCHMARK_INPUT[i].iflash_direct;
embeddedartists 1:b000ac168e46 482 if ((tmp & 0xff000000) != 0x00000000) {
embeddedartists 1:b000ac168e46 483 log->printf("IFLASH data for benchmark %d is at 0x%08x NOT in IFLASH!! Aborting\n", i, tmp);
embeddedartists 1:b000ac168e46 484 return false;
embeddedartists 1:b000ac168e46 485 }
embeddedartists 1:b000ac168e46 486 tmp = (uint32_t)BENCHMARK_INPUT[i].qspi_direct;
embeddedartists 1:b000ac168e46 487 if ((tmp & 0xff000000) != 0x28000000) {
embeddedartists 1:b000ac168e46 488 log->printf("QSPI data for benchmark %d is at 0x%08x NOT in QSPI!! Aborting\n", i, tmp);
embeddedartists 1:b000ac168e46 489 return false;
embeddedartists 1:b000ac168e46 490 }
embeddedartists 1:b000ac168e46 491 }
embeddedartists 1:b000ac168e46 492 }
alindvall 0:b77503796c51 493 return prepareMCI() && prepareUSB() && prepareQSPIFS();
alindvall 0:b77503796c51 494 }
alindvall 0:b77503796c51 495
alindvall 0:b77503796c51 496 static void readFile(const char* fname, uint8_t* dest) {
alindvall 0:b77503796c51 497 FILE* f = fopen(fname, "r");
alindvall 0:b77503796c51 498 if (f != NULL) {
alindvall 0:b77503796c51 499 int num = fread(dest, 1, 1024, f);
alindvall 0:b77503796c51 500 while (num > 0) {
alindvall 0:b77503796c51 501 dest+=num;
alindvall 0:b77503796c51 502 num = fread(dest, 1, 1024, f);
alindvall 0:b77503796c51 503 }
alindvall 0:b77503796c51 504 fclose(f);
alindvall 0:b77503796c51 505 }
alindvall 0:b77503796c51 506 }
alindvall 0:b77503796c51 507
embeddedartists 2:ddc1aa3bea3d 508 static void runReadBenchmarks() {
alindvall 0:b77503796c51 509 RtosLog* log = DMBoard::instance().logger();
alindvall 0:b77503796c51 510 uint32_t times[NUM_BENCHMARKS][5] = {0};
alindvall 0:b77503796c51 511 uint32_t tmp;
alindvall 0:b77503796c51 512 char buff[512];
alindvall 0:b77503796c51 513 Timer t;
alindvall 0:b77503796c51 514 uint8_t* dest = (uint8_t*)malloc(COPYBUF_SIZE);
alindvall 0:b77503796c51 515 if (dest == NULL) {
alindvall 0:b77503796c51 516 log->printf("Failed to allocate 10MBytes as buffer\n");
alindvall 0:b77503796c51 517 return;
alindvall 0:b77503796c51 518 }
alindvall 0:b77503796c51 519
alindvall 0:b77503796c51 520 t.start();
alindvall 0:b77503796c51 521
alindvall 0:b77503796c51 522 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 523 if (!BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 524 // don't include the files for the image decoding in
embeddedartists 3:1716747cba16 525 // the benchmark set
embeddedartists 3:1716747cba16 526 continue;
embeddedartists 3:1716747cba16 527 }
embeddedartists 3:1716747cba16 528
alindvall 0:b77503796c51 529 // MCI
alindvall 0:b77503796c51 530 sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 531 memset(dest, 0, COPYBUF_SIZE);
alindvall 0:b77503796c51 532 tmp = t.read_us();
alindvall 0:b77503796c51 533 readFile(buff, dest);
alindvall 0:b77503796c51 534 times[i][0] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 535 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][0]);
alindvall 0:b77503796c51 536
alindvall 0:b77503796c51 537 //USB
alindvall 0:b77503796c51 538 sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 539 memset(dest, 0, COPYBUF_SIZE);
alindvall 0:b77503796c51 540 tmp = t.read_us();
alindvall 0:b77503796c51 541 readFile(buff, dest);
alindvall 0:b77503796c51 542 times[i][1] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 543 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][1]);
alindvall 0:b77503796c51 544
alindvall 0:b77503796c51 545 //QSPIFS
alindvall 0:b77503796c51 546 sprintf(buff, "/qspi/%s", BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 547 memset(dest, 0, COPYBUF_SIZE);
alindvall 0:b77503796c51 548 tmp = t.read_us();
alindvall 0:b77503796c51 549 readFile(buff, dest);
alindvall 0:b77503796c51 550 times[i][2] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 551 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][2]);
alindvall 0:b77503796c51 552
alindvall 0:b77503796c51 553 //IFLASH
alindvall 0:b77503796c51 554 sprintf(buff, "IFLASH /%s", BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 555 if (BENCHMARK_INPUT[i].iflash_direct != NULL) {
alindvall 0:b77503796c51 556 memset(dest, 0, COPYBUF_SIZE);
alindvall 0:b77503796c51 557 tmp = t.read_us();
alindvall 0:b77503796c51 558 memcpy(dest, BENCHMARK_INPUT[i].iflash_direct, BENCHMARK_INPUT[i].size);
alindvall 0:b77503796c51 559 times[i][3] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 560 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][3]);
alindvall 0:b77503796c51 561 } else {
embeddedartists 3:1716747cba16 562 log->printf("Benchmarking %-30s skipped\n", buff);
alindvall 0:b77503796c51 563 }
alindvall 0:b77503796c51 564
alindvall 0:b77503796c51 565 //QSPI
alindvall 0:b77503796c51 566 sprintf(buff, "QSPI /%s", BENCHMARK_INPUT[i].fname);
alindvall 0:b77503796c51 567 if (BENCHMARK_INPUT[i].qspi_direct != NULL) {
alindvall 0:b77503796c51 568 memset(dest, 0, COPYBUF_SIZE);
alindvall 0:b77503796c51 569 tmp = t.read_us();
alindvall 0:b77503796c51 570 memcpy(dest, BENCHMARK_INPUT[i].qspi_direct, BENCHMARK_INPUT[i].size);
alindvall 0:b77503796c51 571 times[i][4] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 572 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][4]);
alindvall 0:b77503796c51 573 } else {
embeddedartists 3:1716747cba16 574 log->printf("Benchmarking %-30s skipped\n", buff);
alindvall 0:b77503796c51 575 }
alindvall 0:b77503796c51 576 }
alindvall 0:b77503796c51 577
alindvall 0:b77503796c51 578 log->printf("\n\n----\nSummary:\n");
alindvall 0:b77503796c51 579
alindvall 0:b77503796c51 580 log->printf("\n File Information\n");
embeddedartists 3:1716747cba16 581 log->printf("%20s %10s\n", "Filename", "Size");
embeddedartists 3:1716747cba16 582 log->printf("%20s %10s\n", "--------", "----");
alindvall 0:b77503796c51 583 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 584 if (BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 585 log->printf("%20s %10d bytes\n", BENCHMARK_INPUT[i].fname, BENCHMARK_INPUT[i].size);
embeddedartists 3:1716747cba16 586 }
alindvall 0:b77503796c51 587 }
alindvall 0:b77503796c51 588
alindvall 0:b77503796c51 589 log->printf("\n Read times (in us)\n");
embeddedartists 3:1716747cba16 590 log->printf("%20s %10s %10s %10s %10s %10s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]");
embeddedartists 3:1716747cba16 591 log->printf("%20s %10s %10s %10s %10s %10s\n", "--------", "--------", "---", "-------", "--------", "------");
alindvall 0:b77503796c51 592 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 593 if (BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 594 char* p = (char*)dest;
embeddedartists 3:1716747cba16 595 for (int x = 0; x < 5; x++) {
embeddedartists 3:1716747cba16 596 if (times[i][x] == 0) {
embeddedartists 3:1716747cba16 597 p += sprintf(p, "%10s ", "N/A");
embeddedartists 3:1716747cba16 598 } else {
embeddedartists 3:1716747cba16 599 p += sprintf(p, "%10d ", times[i][x]);
embeddedartists 3:1716747cba16 600 }
alindvall 0:b77503796c51 601 }
embeddedartists 3:1716747cba16 602 log->printf("%20s %s\n", BENCHMARK_INPUT[i].fname, dest);
alindvall 0:b77503796c51 603 }
alindvall 0:b77503796c51 604 }
alindvall 0:b77503796c51 605
alindvall 0:b77503796c51 606 log->printf("\n Read speeds\n");
embeddedartists 3:1716747cba16 607 log->printf("%20s %-12s %-12s %-12s %-12s %-12s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]");
embeddedartists 3:1716747cba16 608 log->printf("%20s %s %s %s %s %s\n", "--------", "------------", "------------", "------------", "------------", "------------");
alindvall 0:b77503796c51 609 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 610 if (BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 611 char* p = (char*)dest;
embeddedartists 3:1716747cba16 612 for (int x = 0; x < 5; x++) {
embeddedartists 3:1716747cba16 613 if (times[i][x] == 0) {
embeddedartists 3:1716747cba16 614 p += sprintf(p, "%12s ", "N/A ");
alindvall 0:b77503796c51 615 } else {
embeddedartists 3:1716747cba16 616 double t = times[i][x];
embeddedartists 3:1716747cba16 617 double s = BENCHMARK_INPUT[i].size;
embeddedartists 3:1716747cba16 618 double v = (s*1000000)/t;
embeddedartists 3:1716747cba16 619 if (v < 10000) {
embeddedartists 3:1716747cba16 620 p += sprintf(p, "%#7.2F b/s ", v);
embeddedartists 3:1716747cba16 621 } else if (v < 10000000) {
embeddedartists 3:1716747cba16 622 p += sprintf(p, "%#7.2F Kb/s ", v/1024.0);
embeddedartists 3:1716747cba16 623 } else {
embeddedartists 3:1716747cba16 624 p += sprintf(p, "%#7.2F Mb/s ", v/(1024.0*1024.0));
embeddedartists 3:1716747cba16 625 }
alindvall 0:b77503796c51 626 }
alindvall 0:b77503796c51 627 }
embeddedartists 3:1716747cba16 628 log->printf("%20s %s \n", BENCHMARK_INPUT[i].fname, dest);
alindvall 0:b77503796c51 629 }
alindvall 0:b77503796c51 630 }
alindvall 0:b77503796c51 631
alindvall 0:b77503796c51 632 log->printf("\n\n---\n");
embeddedartists 2:ddc1aa3bea3d 633
embeddedartists 2:ddc1aa3bea3d 634 free(dest);
embeddedartists 2:ddc1aa3bea3d 635 }
embeddedartists 2:ddc1aa3bea3d 636
embeddedartists 2:ddc1aa3bea3d 637 static uint32_t writeFile(const char* fname, int benchId, Timer* t, uint8_t* buff) {
embeddedartists 2:ddc1aa3bea3d 638 uint32_t size = BENCHMARK_INPUT[benchId].size;
embeddedartists 2:ddc1aa3bea3d 639
embeddedartists 2:ddc1aa3bea3d 640 // To make all tests equal all source data is copied to external SDRAM
embeddedartists 2:ddc1aa3bea3d 641 // and from there to the destination file. Only the time from SDRAM to
embeddedartists 2:ddc1aa3bea3d 642 // file is meassured.
embeddedartists 2:ddc1aa3bea3d 643 if (BENCHMARK_INPUT[benchId].iflash_direct == NULL) {
embeddedartists 2:ddc1aa3bea3d 644 memcpy(buff, BENCHMARK_INPUT[benchId].qspi_direct, size);
embeddedartists 2:ddc1aa3bea3d 645 } else {
embeddedartists 2:ddc1aa3bea3d 646 memcpy(buff, BENCHMARK_INPUT[benchId].iflash_direct, size);
embeddedartists 2:ddc1aa3bea3d 647 }
embeddedartists 2:ddc1aa3bea3d 648
embeddedartists 2:ddc1aa3bea3d 649 uint32_t time = t->read_us();
embeddedartists 2:ddc1aa3bea3d 650 int written = 0;
embeddedartists 2:ddc1aa3bea3d 651 FILE* f = fopen(fname, "w");
embeddedartists 2:ddc1aa3bea3d 652 if (f != NULL) {
alindvall 5:788710a95951 653 written = writeInChunks(f, buff, size, (fname[1]=='m'));
embeddedartists 2:ddc1aa3bea3d 654 fclose(f);
embeddedartists 2:ddc1aa3bea3d 655 }
embeddedartists 2:ddc1aa3bea3d 656 if (written == size) {
embeddedartists 2:ddc1aa3bea3d 657 return t->read_us() - time;
embeddedartists 2:ddc1aa3bea3d 658 } else {
embeddedartists 2:ddc1aa3bea3d 659 DMBoard::instance().logger()->printf("Failed to write %s (only wrote %u of %u bytes). Aborting\n", fname, written, size);
embeddedartists 2:ddc1aa3bea3d 660 return 0;
embeddedartists 2:ddc1aa3bea3d 661 }
embeddedartists 2:ddc1aa3bea3d 662 }
embeddedartists 2:ddc1aa3bea3d 663
embeddedartists 2:ddc1aa3bea3d 664 static void runWriteBenchmarks() {
embeddedartists 2:ddc1aa3bea3d 665 RtosLog* log = DMBoard::instance().logger();
embeddedartists 2:ddc1aa3bea3d 666 uint32_t times[NUM_BENCHMARKS][3] = {0};
embeddedartists 2:ddc1aa3bea3d 667 char buff[512];
embeddedartists 2:ddc1aa3bea3d 668 Timer t;
embeddedartists 3:1716747cba16 669
embeddedartists 3:1716747cba16 670 log->printf("Preparing to run WRITE tests...\n");
embeddedartists 2:ddc1aa3bea3d 671
embeddedartists 2:ddc1aa3bea3d 672 // To make all tests equal all source data is copied to external SDRAM
embeddedartists 2:ddc1aa3bea3d 673 // and from there to the destination file. Only the time from SDRAM to
embeddedartists 2:ddc1aa3bea3d 674 // file is meassured.
embeddedartists 2:ddc1aa3bea3d 675 uint8_t* dest = (uint8_t*)malloc(COPYBUF_SIZE);
embeddedartists 2:ddc1aa3bea3d 676 if (dest == NULL) {
embeddedartists 2:ddc1aa3bea3d 677 log->printf("Failed to allocate 10MBytes as buffer\n");
embeddedartists 2:ddc1aa3bea3d 678 return;
embeddedartists 2:ddc1aa3bea3d 679 }
embeddedartists 2:ddc1aa3bea3d 680
embeddedartists 2:ddc1aa3bea3d 681 // Clear the entire QSPI file system
embeddedartists 2:ddc1aa3bea3d 682 if (qspifs->format(QSPIFS_SIZE_MB) == 0) {
embeddedartists 2:ddc1aa3bea3d 683 log->printf("Formatting successful\n");
embeddedartists 2:ddc1aa3bea3d 684 } else {
embeddedartists 2:ddc1aa3bea3d 685 log->printf("Failed to format QSPI file system!\n");
embeddedartists 2:ddc1aa3bea3d 686 return;
embeddedartists 2:ddc1aa3bea3d 687 }
embeddedartists 2:ddc1aa3bea3d 688
embeddedartists 2:ddc1aa3bea3d 689 // For uSD and USB formatting is a bad idea as the memory
embeddedartists 2:ddc1aa3bea3d 690 // might contain other important file. Just delete the files
embeddedartists 2:ddc1aa3bea3d 691 // we are using instead.
embeddedartists 2:ddc1aa3bea3d 692 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 2:ddc1aa3bea3d 693 // MCI
embeddedartists 2:ddc1aa3bea3d 694 sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 2:ddc1aa3bea3d 695 remove(buff);
embeddedartists 2:ddc1aa3bea3d 696
embeddedartists 2:ddc1aa3bea3d 697 //USB
embeddedartists 2:ddc1aa3bea3d 698 sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 2:ddc1aa3bea3d 699 remove(buff);
embeddedartists 2:ddc1aa3bea3d 700 }
embeddedartists 2:ddc1aa3bea3d 701
embeddedartists 2:ddc1aa3bea3d 702 t.start();
embeddedartists 2:ddc1aa3bea3d 703
embeddedartists 2:ddc1aa3bea3d 704 // Do the benchmarking
embeddedartists 3:1716747cba16 705 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 706 if (!BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 707 // don't include the files for the image decoding in
embeddedartists 3:1716747cba16 708 // the benchmark set
embeddedartists 3:1716747cba16 709 continue;
embeddedartists 3:1716747cba16 710 }
embeddedartists 3:1716747cba16 711
embeddedartists 2:ddc1aa3bea3d 712 // MCI
embeddedartists 2:ddc1aa3bea3d 713 sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 2:ddc1aa3bea3d 714 memset(dest, 0, COPYBUF_SIZE);
embeddedartists 2:ddc1aa3bea3d 715 times[i][0] = writeFile(buff, i, &t, dest);
embeddedartists 3:1716747cba16 716 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][0]);
embeddedartists 2:ddc1aa3bea3d 717
embeddedartists 2:ddc1aa3bea3d 718 //USB
embeddedartists 2:ddc1aa3bea3d 719 sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 2:ddc1aa3bea3d 720 memset(dest, 0, COPYBUF_SIZE);
embeddedartists 2:ddc1aa3bea3d 721 times[i][1] = writeFile(buff, i, &t, dest);
embeddedartists 3:1716747cba16 722 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][1]);
embeddedartists 2:ddc1aa3bea3d 723
embeddedartists 2:ddc1aa3bea3d 724 //QSPIFS
embeddedartists 2:ddc1aa3bea3d 725 sprintf(buff, "/qspi/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 2:ddc1aa3bea3d 726 memset(dest, 0, COPYBUF_SIZE);
embeddedartists 2:ddc1aa3bea3d 727 times[i][2] = writeFile(buff, i, &t, dest);
embeddedartists 3:1716747cba16 728 log->printf("Benchmarking %-30s took %8uus\n", buff, times[i][2]);
embeddedartists 2:ddc1aa3bea3d 729 }
embeddedartists 2:ddc1aa3bea3d 730
embeddedartists 2:ddc1aa3bea3d 731 log->printf("\n\n----\nSummary:\n");
embeddedartists 2:ddc1aa3bea3d 732
embeddedartists 2:ddc1aa3bea3d 733 log->printf("\n File Information\n");
embeddedartists 3:1716747cba16 734 log->printf("%20s %10s\n", "Filename", "Size");
embeddedartists 3:1716747cba16 735 log->printf("%20s %10s\n", "--------", "----");
embeddedartists 2:ddc1aa3bea3d 736 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 737 if (BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 738 log->printf("%20s %10d bytes\n", BENCHMARK_INPUT[i].fname, BENCHMARK_INPUT[i].size);
embeddedartists 3:1716747cba16 739 }
embeddedartists 2:ddc1aa3bea3d 740 }
embeddedartists 2:ddc1aa3bea3d 741
embeddedartists 2:ddc1aa3bea3d 742 log->printf("\n Write times (in us)\n");
embeddedartists 3:1716747cba16 743 log->printf("%20s %10s %10s %10s\n", "Filename", "uSD Card", "USB", "QSPI FS");
embeddedartists 3:1716747cba16 744 log->printf("%20s %10s %10s %10s\n", "--------", "--------", "---", "-------");
embeddedartists 3:1716747cba16 745 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 746 if (BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 747 char* p = (char*)dest;
embeddedartists 3:1716747cba16 748 for (int x = 0; x < 3; x++) {
embeddedartists 3:1716747cba16 749 if (times[i][x] == 0) {
embeddedartists 3:1716747cba16 750 p += sprintf(p, "%10s ", "N/A");
embeddedartists 3:1716747cba16 751 } else {
embeddedartists 3:1716747cba16 752 p += sprintf(p, "%10d ", times[i][x]);
embeddedartists 3:1716747cba16 753 }
embeddedartists 3:1716747cba16 754 }
embeddedartists 3:1716747cba16 755 log->printf("%20s %s\n", BENCHMARK_INPUT[i].fname, dest);
embeddedartists 3:1716747cba16 756 }
embeddedartists 3:1716747cba16 757 }
embeddedartists 3:1716747cba16 758
embeddedartists 3:1716747cba16 759 log->printf("\n Write speeds\n");
embeddedartists 3:1716747cba16 760 log->printf("%20s %-12s %-12s %-12s\n", "Filename", "uSD Card", "USB", "QSPI FS");
embeddedartists 3:1716747cba16 761 log->printf("%20s %s %s %s\n", "--------", "------------", "------------", "------------");
embeddedartists 3:1716747cba16 762 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 763 if (BENCHMARK_INPUT[i].rw) {
embeddedartists 3:1716747cba16 764 char* p = (char*)dest;
embeddedartists 3:1716747cba16 765 for (int x = 0; x < 3; x++) {
embeddedartists 3:1716747cba16 766 if (times[i][x] == 0) {
embeddedartists 3:1716747cba16 767 p += sprintf(p, "%12s ", "N/A ");
embeddedartists 3:1716747cba16 768 } else {
embeddedartists 3:1716747cba16 769 double t = times[i][x];
embeddedartists 3:1716747cba16 770 double s = BENCHMARK_INPUT[i].size;
embeddedartists 3:1716747cba16 771 double v = (s*1000000)/t;
embeddedartists 3:1716747cba16 772 if (v < 10000) {
embeddedartists 3:1716747cba16 773 p += sprintf(p, "%#7.2F b/s ", v);
embeddedartists 3:1716747cba16 774 } else if (v < 10000000) {
embeddedartists 3:1716747cba16 775 p += sprintf(p, "%#7.2F Kb/s ", v/1024.0);
embeddedartists 3:1716747cba16 776 } else {
embeddedartists 3:1716747cba16 777 p += sprintf(p, "%#7.2F Mb/s ", v/(1024.0*1024.0));
embeddedartists 3:1716747cba16 778 }
embeddedartists 3:1716747cba16 779 }
embeddedartists 3:1716747cba16 780 }
embeddedartists 3:1716747cba16 781 log->printf("%20s %s \n", BENCHMARK_INPUT[i].fname, dest);
embeddedartists 3:1716747cba16 782 }
embeddedartists 3:1716747cba16 783 }
embeddedartists 3:1716747cba16 784
embeddedartists 3:1716747cba16 785 log->printf("\n\n---\n");
embeddedartists 3:1716747cba16 786
embeddedartists 3:1716747cba16 787 free(dest);
embeddedartists 3:1716747cba16 788 }
embeddedartists 3:1716747cba16 789
embeddedartists 3:1716747cba16 790 static void runImageBenchmarks() {
embeddedartists 3:1716747cba16 791 RtosLog* log = DMBoard::instance().logger();
embeddedartists 3:1716747cba16 792 uint32_t times[NUM_BENCHMARKS][5] = {0};
embeddedartists 3:1716747cba16 793 uint32_t tmp;
embeddedartists 3:1716747cba16 794 char buff[512];
embeddedartists 3:1716747cba16 795 int result;
embeddedartists 3:1716747cba16 796 Image::ImageData_t imgData;
embeddedartists 3:1716747cba16 797 Timer t;
embeddedartists 3:1716747cba16 798
embeddedartists 3:1716747cba16 799 t.start();
embeddedartists 3:1716747cba16 800
embeddedartists 2:ddc1aa3bea3d 801 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 802
embeddedartists 3:1716747cba16 803 // MCI
embeddedartists 3:1716747cba16 804 sprintf(buff, "/mci/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 3:1716747cba16 805 tmp = t.read_us();
embeddedartists 3:1716747cba16 806 result = Image::decode(buff, Image::RES_16BIT, &imgData);
embeddedartists 3:1716747cba16 807 times[i][0] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 808 if (result == 0) {
embeddedartists 3:1716747cba16 809 log->printf("Decoding %-30s took %8uus\n", buff, times[i][0]);
embeddedartists 3:1716747cba16 810 if (imgData.pointerToFree != NULL) {
embeddedartists 3:1716747cba16 811 free(imgData.pointerToFree);
embeddedartists 3:1716747cba16 812 imgData.pointerToFree = NULL;
embeddedartists 3:1716747cba16 813 }
embeddedartists 3:1716747cba16 814 } else {
embeddedartists 3:1716747cba16 815 log->printf("Decoding %-30s failed\n", buff);
embeddedartists 3:1716747cba16 816 times[i][0] = 0;
embeddedartists 3:1716747cba16 817 }
embeddedartists 3:1716747cba16 818
embeddedartists 3:1716747cba16 819 //USB
embeddedartists 3:1716747cba16 820 sprintf(buff, "/usb/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 3:1716747cba16 821 tmp = t.read_us();
embeddedartists 3:1716747cba16 822 result = Image::decode(buff, Image::RES_16BIT, &imgData);
embeddedartists 3:1716747cba16 823 times[i][1] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 824 if (result == 0) {
embeddedartists 3:1716747cba16 825 log->printf("Decoding %-30s took %8uus\n", buff, times[i][1]);
embeddedartists 3:1716747cba16 826 if (imgData.pointerToFree != NULL) {
embeddedartists 3:1716747cba16 827 free(imgData.pointerToFree);
embeddedartists 3:1716747cba16 828 imgData.pointerToFree = NULL;
embeddedartists 3:1716747cba16 829 }
embeddedartists 3:1716747cba16 830 } else {
embeddedartists 3:1716747cba16 831 log->printf("Decoding %-30s failed\n", buff);
embeddedartists 3:1716747cba16 832 times[i][1] = 0;
embeddedartists 3:1716747cba16 833 }
embeddedartists 3:1716747cba16 834
embeddedartists 3:1716747cba16 835 //QSPIFS
embeddedartists 3:1716747cba16 836 sprintf(buff, "/qspi/%s", BENCHMARK_INPUT[i].fname);
embeddedartists 3:1716747cba16 837 tmp = t.read_us();
embeddedartists 3:1716747cba16 838 result = Image::decode(buff, Image::RES_16BIT, &imgData);
embeddedartists 3:1716747cba16 839 times[i][2] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 840 if (result == 0) {
embeddedartists 3:1716747cba16 841 log->printf("Decoding %-30s took %8uus\n", buff, times[i][2]);
embeddedartists 3:1716747cba16 842 if (imgData.pointerToFree != NULL) {
embeddedartists 3:1716747cba16 843 free(imgData.pointerToFree);
embeddedartists 3:1716747cba16 844 imgData.pointerToFree = NULL;
embeddedartists 3:1716747cba16 845 }
embeddedartists 3:1716747cba16 846 } else {
embeddedartists 3:1716747cba16 847 log->printf("Decoding %-30s failed\n", buff);
embeddedartists 3:1716747cba16 848 times[i][2] = 0;
embeddedartists 3:1716747cba16 849 }
embeddedartists 3:1716747cba16 850
embeddedartists 3:1716747cba16 851 //IFLASH
embeddedartists 3:1716747cba16 852 sprintf(buff, "IFLASH /%s", BENCHMARK_INPUT[i].fname);
embeddedartists 3:1716747cba16 853 if (BENCHMARK_INPUT[i].iflash_direct != NULL) {
embeddedartists 3:1716747cba16 854 tmp = t.read_us();
embeddedartists 3:1716747cba16 855 result = Image::decode(BENCHMARK_INPUT[i].iflash_direct, BENCHMARK_INPUT[i].size, Image::RES_16BIT, &imgData);
embeddedartists 3:1716747cba16 856 times[i][3] = 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][3]);
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][3] = 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 //QSPI
embeddedartists 3:1716747cba16 872 sprintf(buff, "QSPI /%s", BENCHMARK_INPUT[i].fname);
embeddedartists 3:1716747cba16 873 if (BENCHMARK_INPUT[i].qspi_direct != NULL) {
embeddedartists 3:1716747cba16 874 tmp = t.read_us();
embeddedartists 3:1716747cba16 875 result = Image::decode(BENCHMARK_INPUT[i].qspi_direct, BENCHMARK_INPUT[i].size, Image::RES_16BIT, &imgData);
embeddedartists 3:1716747cba16 876 times[i][4] = t.read_us() - tmp;
embeddedartists 3:1716747cba16 877 if (result == 0) {
embeddedartists 3:1716747cba16 878 log->printf("Decoding %-30s took %8uus\n", buff, times[i][4]);
embeddedartists 3:1716747cba16 879 if (imgData.pointerToFree != NULL) {
embeddedartists 3:1716747cba16 880 free(imgData.pointerToFree);
embeddedartists 3:1716747cba16 881 imgData.pointerToFree = NULL;
embeddedartists 3:1716747cba16 882 }
embeddedartists 3:1716747cba16 883 } else {
embeddedartists 3:1716747cba16 884 log->printf("Decoding %-30s failed\n", buff);
embeddedartists 3:1716747cba16 885 times[i][4] = 0;
embeddedartists 3:1716747cba16 886 }
embeddedartists 3:1716747cba16 887 } else {
embeddedartists 3:1716747cba16 888 log->printf("Decoding %-30s skipped\n", buff);
embeddedartists 3:1716747cba16 889 }
embeddedartists 3:1716747cba16 890 }
embeddedartists 3:1716747cba16 891
embeddedartists 3:1716747cba16 892 log->printf("\n\n----\nSummary:\n");
embeddedartists 3:1716747cba16 893
embeddedartists 3:1716747cba16 894 log->printf("\n File Information\n");
embeddedartists 3:1716747cba16 895 log->printf("%20s %10s\n", "Filename", "Size");
embeddedartists 3:1716747cba16 896 log->printf("%20s %10s\n", "--------", "----");
embeddedartists 3:1716747cba16 897 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 898 log->printf("%20s %10d bytes\n", BENCHMARK_INPUT[i].fname, BENCHMARK_INPUT[i].size);
embeddedartists 3:1716747cba16 899 }
embeddedartists 3:1716747cba16 900
embeddedartists 3:1716747cba16 901 log->printf("\n Decode times (in us)\n");
embeddedartists 3:1716747cba16 902 log->printf("%20s %10s %10s %10s %10s %10s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]");
embeddedartists 3:1716747cba16 903 log->printf("%20s %10s %10s %10s %10s %10s\n", "--------", "--------", "---", "-------", "--------", "------");
embeddedartists 3:1716747cba16 904 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 905 char* p = (char*)buff;
embeddedartists 3:1716747cba16 906 for (int x = 0; x < 5; x++) {
embeddedartists 2:ddc1aa3bea3d 907 if (times[i][x] == 0) {
embeddedartists 2:ddc1aa3bea3d 908 p += sprintf(p, "%10s ", "N/A");
embeddedartists 2:ddc1aa3bea3d 909 } else {
embeddedartists 2:ddc1aa3bea3d 910 p += sprintf(p, "%10d ", times[i][x]);
embeddedartists 2:ddc1aa3bea3d 911 }
embeddedartists 2:ddc1aa3bea3d 912 }
embeddedartists 3:1716747cba16 913 log->printf("%20s %s\n", BENCHMARK_INPUT[i].fname, buff);
embeddedartists 2:ddc1aa3bea3d 914 }
embeddedartists 2:ddc1aa3bea3d 915
embeddedartists 3:1716747cba16 916 log->printf("\n Decode speeds\n");
embeddedartists 3:1716747cba16 917 log->printf("%20s %-12s %-12s %-12s %-12s %-12s\n", "Filename", "uSD Card", "USB", "QSPI FS", "IFLASH[]", "QSPI[]");
embeddedartists 3:1716747cba16 918 log->printf("%20s %s %s %s %s %s\n", "--------", "------------", "------------", "------------", "------------", "------------");
embeddedartists 2:ddc1aa3bea3d 919 for (int i = 0; i < NUM_BENCHMARKS; i++) {
embeddedartists 3:1716747cba16 920 char* p = (char*)buff;
embeddedartists 3:1716747cba16 921 for (int x = 0; x < 5; x++) {
embeddedartists 2:ddc1aa3bea3d 922 if (times[i][x] == 0) {
embeddedartists 2:ddc1aa3bea3d 923 p += sprintf(p, "%12s ", "N/A ");
embeddedartists 2:ddc1aa3bea3d 924 } else {
embeddedartists 2:ddc1aa3bea3d 925 double t = times[i][x];
embeddedartists 2:ddc1aa3bea3d 926 double s = BENCHMARK_INPUT[i].size;
embeddedartists 2:ddc1aa3bea3d 927 double v = (s*1000000)/t;
embeddedartists 2:ddc1aa3bea3d 928 if (v < 10000) {
embeddedartists 2:ddc1aa3bea3d 929 p += sprintf(p, "%#7.2F b/s ", v);
embeddedartists 2:ddc1aa3bea3d 930 } else if (v < 10000000) {
embeddedartists 2:ddc1aa3bea3d 931 p += sprintf(p, "%#7.2F Kb/s ", v/1024.0);
embeddedartists 2:ddc1aa3bea3d 932 } else {
embeddedartists 2:ddc1aa3bea3d 933 p += sprintf(p, "%#7.2F Mb/s ", v/(1024.0*1024.0));
embeddedartists 2:ddc1aa3bea3d 934 }
embeddedartists 2:ddc1aa3bea3d 935 }
embeddedartists 2:ddc1aa3bea3d 936 }
embeddedartists 3:1716747cba16 937 log->printf("%20s %s \n", BENCHMARK_INPUT[i].fname, buff);
embeddedartists 2:ddc1aa3bea3d 938 }
embeddedartists 2:ddc1aa3bea3d 939
embeddedartists 2:ddc1aa3bea3d 940 log->printf("\n\n---\n");
alindvall 0:b77503796c51 941 }
alindvall 0:b77503796c51 942
alindvall 0:b77503796c51 943 /******************************************************************************
alindvall 0:b77503796c51 944 * Main
alindvall 0:b77503796c51 945 *****************************************************************************/
alindvall 0:b77503796c51 946
alindvall 0:b77503796c51 947 int main()
alindvall 0:b77503796c51 948 {
alindvall 0:b77503796c51 949 DMBoard::BoardError err;
alindvall 0:b77503796c51 950 DMBoard* board = &DMBoard::instance();
alindvall 0:b77503796c51 951 RtosLog* log = board->logger();
alindvall 0:b77503796c51 952
alindvall 0:b77503796c51 953 do {
alindvall 0:b77503796c51 954 err = board->init();
alindvall 0:b77503796c51 955 if (err != DMBoard::Ok) {
alindvall 0:b77503796c51 956 log->printf("Failed to initialize the board, got error %d\r\n", err);
alindvall 0:b77503796c51 957 break;
alindvall 0:b77503796c51 958 }
alindvall 0:b77503796c51 959
embeddedartists 6:47b4bed9fa13 960 log->printf("\n\nBenchmarking. (Built " __DATE__ " at " __TIME__ ")\n\n");
alindvall 0:b77503796c51 961
alindvall 0:b77503796c51 962 log->printf("Preparing file systems for benchmarking\n");
alindvall 0:b77503796c51 963 if (!prepare()) {
alindvall 0:b77503796c51 964 log->printf("Failed to prepare for benchmarking\r\n");
alindvall 0:b77503796c51 965 break;
alindvall 0:b77503796c51 966 }
alindvall 0:b77503796c51 967
embeddedartists 2:ddc1aa3bea3d 968 runReadBenchmarks();
embeddedartists 3:1716747cba16 969 runImageBenchmarks();
embeddedartists 2:ddc1aa3bea3d 970
embeddedartists 6:47b4bed9fa13 971 ThisThread::sleep_for(1000);
embeddedartists 2:ddc1aa3bea3d 972 log->printf("Press the USER button to run WRITE tests!\n");
embeddedartists 2:ddc1aa3bea3d 973 while(!board->buttonPressed()) {
embeddedartists 6:47b4bed9fa13 974 ThisThread::sleep_for(20);
embeddedartists 2:ddc1aa3bea3d 975 }
embeddedartists 2:ddc1aa3bea3d 976 while(board->buttonPressed()) {
embeddedartists 6:47b4bed9fa13 977 ThisThread::sleep_for(20);
embeddedartists 2:ddc1aa3bea3d 978 }
embeddedartists 2:ddc1aa3bea3d 979
embeddedartists 2:ddc1aa3bea3d 980 runWriteBenchmarks();
alindvall 0:b77503796c51 981
alindvall 0:b77503796c51 982 } while(false);
alindvall 0:b77503796c51 983
alindvall 0:b77503796c51 984 if (err != DMBoard::Ok) {
alindvall 0:b77503796c51 985 log->printf("\nTERMINATING\n");
alindvall 0:b77503796c51 986 }
alindvall 0:b77503796c51 987
alindvall 0:b77503796c51 988 while(true) {
embeddedartists 6:47b4bed9fa13 989 ThisThread::sleep_for(1000);
alindvall 0:b77503796c51 990 }
alindvall 0:b77503796c51 991 }
alindvall 0:b77503796c51 992