Testing the speed of an internal card reader with Disks
In order to find the maximum throughput via the internal card reader the other components must be faster (the read/write process on both sides of the card reader, and in particular, the card. And I think the real card speed [which may differ from the nominal speed] can only be verified in a system with a card reader, that is not the bottleneck (for example an adapter via USB 3).
We can expect that a good USB 3 adapter will be at least as fast as the memory card used in the test. We can also expect that an internal HDD or SSD is faster than the card. So it should be enough that the card and the USB 3 adapter are faster than the internal card reader in order to test the speed for reading and/or writing (of the internal card reader).
A good test procedure includes flushing the buffers. Let us rely on Disks alias gnome-disks
and simply run it using
If using the internal card reader takes longer time, you can conclude that it is the bottleneck.
General discussion including testing also other hardware
It is very important that you test not only what is the output from for example dd
or pv
, but you should measure the time of the read or write command including flushing the buffers. The following method should work in linux,
time ( read or write command ; sync )
and then divide the amount of data written by the 'real' time to get the real speed.
It is a good idea to test read/write of a single big file and of 'many small files'. (Writing 'many small files' is often much slower than writing a single big file measured in MB/s).
You can use some standard test or design a test for your particular use case, which may rank combinations of hardware and software in a different way from the standard test.
For write tests it is important that reading or creating the input is not the bottleneck. Running in a live system with the data in RAM is one alternative. For read tests you can write to /dev/null
.
To find the bottleneck you can try with different
- cards (different nominal speed)
- adapters
- USB ports or built-in card slots
- computers
- operating systems
If all you want is elapsed time, then with zsh or ksh93:
$ typeset -F SECONDS=0; sleep 1; print "$SECONDS"
1.0012850761
Now, whether that kind of precision makes sense is another matter.
Best Answer
Read also time(7) (assuming a Linux system). You can not only use time(1) but also some time functions (e.g. clock(3), clock_gettime(2), etc...) inside the program.
See also this.
Look also into gprof(1), perf(1), oprofile(1). You may want to invoke the GCC compiler specifically (e.g.
gcc -pg
forgprof
) for profiling and/or benchmarking, which has some overhead.