You are almost certainly doing something wrong and the difference can often be a lot more than that.I am certainly doing things wrong somewhere because RAM access "should be" ten time shorter.
This is the time taken to create a 100MB file in my home directory on SD Card ...
Code:
pi@Pi3B:~ $ dd bs=1M count=100 if=/dev/zero of=./100MB.bin100+0 records in100+0 records out104857600 bytes (105 MB, 100 MiB) copied, 31.2755 s, 3.4 MB/s
Code:
pi@Pi3B:~ $ dd bs=1M count=100 if=/dev/zero of=/tmp/100MB.bin100+0 records in100+0 records out104857600 bytes (105 MB, 100 MiB) copied, 0.348941 s, 301 MB/s
Code:
.-----------.--------.------------. | Seconds | MB/s | Per byte | .----------|-----------|--------|------------| | SD Card | 31.2755 | 3.4 | 298.2 ns | | Ram Disk | 0.3489 | 301 | 3.3 ns | `----------^-----------^--------^------------'
Code:
import timepayload_100MB = bytearray(100 * 1024 * 1024)def Write_100MB(file): s = time.time() with open(file, "wb") as f: f.write(payload_100MB) e = time.time() print("{} \t = {:5.3f} seconds".format(file, e - s))Write_100MB("./100MB.bin")Write_100MB("/tmp/100MB.bin")
Code:
pi@Pi3B:~ $ python3 write_110MB.py./100MB.bin = 0.718 seconds/tmp/100MB.bin = 0.250 seconds
I'm not sure exactly what you are trying to measure or why. Write to RAM will be a lot quicker than write to SD Card.
Statistics: Posted by hippy — Sun Jul 28, 2024 2:16 pm