Skip to content

Instantly share code, notes, and snippets.

@Roman-Port
Created April 21, 2022 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Roman-Port/f35e333fa9606e894873dbb234515a8b to your computer and use it in GitHub Desktop.
Save Roman-Port/f35e333fa9606e894873dbb234515a8b to your computer and use it in GitHub Desktop.
void run_benchmark() {
int target = 2600000 * 5;
int blockSize = sizeof(buffer);
while (blockSize >= 256) {
//Do benchmark
FILE* output = fopen("/sdcard/out.bin", "wb");
int64_t start = esp_timer_get_time();
int remaining = target;
while (remaining > 0) {
remaining -= fwrite(buffer, 1, blockSize > remaining ? remaining : blockSize, output);
}
int64_t end = esp_timer_get_time();
fclose(output);
//Log timing info
double speed = target / ((end - start) / 1000000.0);
printf("BS %i -> %f KB/sec\n", blockSize, (float)(speed / 1024));
//Prepare next test
blockSize /= 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment