PX4 Firmware
PX4 Autopilot Software http://px4.io
sd_bench.c File Reference

SD Card benchmarking. More...

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/module.h>
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/log.h>
#include <drivers/drv_hrt.h>
Include dependency graph for sd_bench.c:

Go to the source code of this file.

Functions

static void usage (void)
 
static void write_test (int fd, uint8_t *block, int block_size)
 sequential write speed test More...
 
static unsigned int time_fsync (int fd)
 Measure the time for fsync. More...
 
__EXPORT int sd_bench_main (int argc, char *argv[])
 

Variables

static const char * BENCHMARK_FILE = PX4_STORAGEDIR"/benchmark.tmp"
 
static int num_runs
 number of runs More...
 
static int run_duration
 duration of a single run [ms] More...
 
static bool synchronized
 call fsync after each block? More...
 

Detailed Description

SD Card benchmarking.

Definition in file sd_bench.c.

Function Documentation

◆ sd_bench_main()

int sd_bench_main ( int  argc,
char *  argv[] 
)

Definition at line 85 of file sd_bench.c.

References BENCHMARK_FILE, num_runs, run_duration, usage(), and write_test().

Here is the call graph for this function:

◆ time_fsync()

unsigned int time_fsync ( int  fd)
inlinestatic

Measure the time for fsync.

Parameters
fd
Returns
time in ms

Definition at line 155 of file sd_bench.c.

References hrt_absolute_time(), hrt_abstime, and hrt_elapsed_time().

Referenced by write_test().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usage()

static void usage ( void  )
static

Definition at line 73 of file sd_bench.c.

Referenced by sd_bench_main().

Here is the caller graph for this function:

◆ write_test()

void write_test ( int  fd,
uint8_t *  block,
int  block_size 
)
static

sequential write speed test

Definition at line 162 of file sd_bench.c.

References hrt_absolute_time(), hrt_abstime, hrt_elapsed_time(), num_runs, run_duration, start(), time_fsync(), and write().

Referenced by sd_bench_main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BENCHMARK_FILE

const char* BENCHMARK_FILE = PX4_STORAGEDIR"/benchmark.tmp"
static

Definition at line 66 of file sd_bench.c.

Referenced by sd_bench_main().

◆ num_runs

int num_runs
static

number of runs

Definition at line 68 of file sd_bench.c.

Referenced by sd_bench_main(), and write_test().

◆ run_duration

int run_duration
static

duration of a single run [ms]

Definition at line 69 of file sd_bench.c.

Referenced by sd_bench_main(), and write_test().

◆ synchronized

bool synchronized
static

call fsync after each block?

Definition at line 70 of file sd_bench.c.