Cut down 'tests file' for debugging

This commit is contained in:
px4dev 2013-09-03 21:22:03 -07:00
parent ed4b34547c
commit 514d32e961
1 changed files with 41 additions and 2 deletions

View File

@ -52,6 +52,8 @@
int int
test_file(int argc, char *argv[]) test_file(int argc, char *argv[])
{ {
const iterations = 10;
/* check if microSD card is mounted */ /* check if microSD card is mounted */
struct stat buffer; struct stat buffer;
if (stat("/fs/microsd/", &buffer)) { if (stat("/fs/microsd/", &buffer)) {
@ -67,7 +69,43 @@ test_file(int argc, char *argv[])
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
start = hrt_absolute_time(); start = hrt_absolute_time();
for (unsigned i = 0; i < 1024; i++) { for (unsigned i = 0; i < iterations; i++) {
perf_begin(wperf);
write(fd, buf, sizeof(buf));
perf_end(wperf);
}
end = hrt_absolute_time();
close(fd);
warnx("%dKiB in %llu microseconds", iterations / 2, end - start);
perf_print_counter(wperf);
perf_free(wperf);
return 0;
}
#if 0
int
test_file(int argc, char *argv[])
{
const iterations = 1024;
/* check if microSD card is mounted */
struct stat buffer;
if (stat("/fs/microsd/", &buffer)) {
warnx("no microSD card mounted, aborting file test");
return 1;
}
uint8_t buf[512];
hrt_abstime start, end;
perf_counter_t wperf = perf_alloc(PC_ELAPSED, "SD writes");
int fd = open("/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
memset(buf, 0, sizeof(buf));
start = hrt_absolute_time();
for (unsigned i = 0; i < iterations; i++) {
perf_begin(wperf); perf_begin(wperf);
write(fd, buf, sizeof(buf)); write(fd, buf, sizeof(buf));
perf_end(wperf); perf_end(wperf);
@ -78,7 +116,7 @@ test_file(int argc, char *argv[])
unlink("/fs/microsd/testfile"); unlink("/fs/microsd/testfile");
warnx("512KiB in %llu microseconds", end - start); warnx("%dKiB in %llu microseconds", iterations / 2, end - start);
perf_print_counter(wperf); perf_print_counter(wperf);
perf_free(wperf); perf_free(wperf);
@ -112,3 +150,4 @@ test_file(int argc, char *argv[])
return 0; return 0;
} }
#endif