SDHCFileSystemの書き込み速度を調べてみた

SDHCFileSystem

SDFileSystemでは2GB以上のsdの書き込みができないので、後を考えてSDHCFileSystemを試してみた。

メディア

テストに使用したメディアは、SDHC 4GB Class4。

テスト内容

Import program_test_SDHCFileSystem

Test program for SDHCFileSystem performance test.

fopen()/fwrite()/fclose()で、任意のサイズのファイルを書き込みfwrite()毎の時間(マイクロ秒)をTimerで測る。

fwrite()で一度に書き込むデータサイズ(blockとする)を変えてみる。

byteあたりの平均時間、最大時間、blockあたりの平均時間、最大時間を記録表示。

SPI Frequency

1MHz(SDHCFileSystemのデフォルト)と2MHzとで試した

結果

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=1bytes TotalTime=88627215us
Time(us): max=171799(4129280) avg=2 max(block)=171799(4129280) avg(block)=2

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=2bytes TotalTime=79105961us
Time(us): max=85767(1589504) avg=1 max(block)=171535(1589504) avg(block)=2

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=5bytes TotalTime=74320038us
Time(us): max=29131(558387) avg=0 max(block)=145655(558387) avg(block)=2

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=10bytes TotalTime=72589086us
Time(us): max=14675(184166) avg=0 max(block)=146751(184166) avg(block)=2

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=20bytes TotalTime=73730640us
Time(us): max=7353(44569) avg=0 max(block)=147070(44569) avg(block)=2

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=50bytes TotalTime=70967808us
Time(us): max=3543(71444) avg=0 max(block)=177157(71444) avg(block)=6

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=100bytes TotalTime=70787428us
Time(us): max=1716(26219) avg=1 max(block)=171664(26219) avg(block)=110

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=256bytes TotalTime=70613653us
Time(us): max=670(6530) avg=9 max(block)=171629(6530) avg(block)=2334

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=512bytes TotalTime=70767243us
Time(us): max=273(2504) avg=13 max(block)=140247(2504) avg(block)=7031

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=1024bytes TotalTime=72460560us
Time(us): max=388(4420) avg=11 max(block)=397541(4420) avg(block)=11912

SPIFreq=1000000Hz TotalBytes=5120000 (Block)=2048bytes TotalTime=70484194us
Time(us): max=250(1746) avg=13 max(block)=512258(1746) avg(block)=26951

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=1bytes TotalTime=68154899us
Time(us): max=158561(4129280) avg=2 max(block)=158561(4129280) avg(block)=2

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=2bytes TotalTime=58430210us
Time(us): max=72557(1871104) avg=1 max(block)=145114(1871104) avg(block)=2

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=5bytes TotalTime=53481268us
Time(us): max=28823(558387) avg=0 max(block)=144118(558387) avg(block)=2

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=10bytes TotalTime=51634930us
Time(us): max=14475(184166) avg=0 max(block)=144756(184166) avg(block)=2

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=20bytes TotalTime=52891725us
Time(us): max=7214(44569) avg=0 max(block)=144295(44569) avg(block)=2

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=50bytes TotalTime=50186990us
Time(us): max=3142(71444) avg=0 max(block)=157122(71444) avg(block)=5

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=100bytes TotalTime=49894523us
Time(us): max=1381(31825) avg=0 max(block)=138170(31825) avg(block)=77

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=256bytes TotalTime=49802619us
Time(us): max=562(8730) avg=6 max(block)=144063(8730) avg(block)=1547

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=512bytes TotalTime=50031791us
Time(us): max=270(2504) avg=34 max(block)=138431(2504) avg(block)=17804

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=1024bytes TotalTime=51656963us
Time(us): max=380(344) avg=7 max(block)=389200(344) avg(block)=7785

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=2048bytes TotalTime=49686362us
Time(us): max=246(1746) avg=8 max(block)=504067(1746) avg(block)=18508

SPIFreq=2000000Hz TotalBytes=5120000 (Block)=4096bytes TotalTime=49274220us
Time(us): max=174(640) avg=8 max(block)=714698(640) avg(block)=36960
  • SPI Frequencyの変更は影響がある
  • 1byteあたりの時間は100byteブロック以上あたりから増えてくるが、最大時間は小さくなる傾向
  • 最大時間との兼ね合いでみるとfwrite()に渡すデータは256〜512byte程度の単位で渡すのが良いか

別に時間傾向を表示させてみたが、極端に時間がかかるのは連続でなく1回かかるとすぐ平均程度に戻るので、maxの書き込み時間を考慮してqueueing等を行うべきかと思われる。


Please log in to post comments.