[Question] speed of imwrite
이전 댓글 표시
I am using imwrite to write the .bmp file, and wondering some information about its speed.
I was writing 1024 x 768 bmp, which is 768 KB, and matlab finished the writing on my computer with about 8 ms, which is equal to 93 MB/s. I have tested the writing speed of my hard disk, which is about 100 MB/s. So, it is fair.
And then, I used the Ram disk (there are softwares supportting to use the ram as an extra temporal hard disk while the computer is on.). The writing speed of it is about 3 GB/s. (I use some hard disk testing software to measure.) However, when I use matlab to write the file in that Ram disk, the necessary time is still about 8 ms. It seems to me that matlab is limited to something else, not just the hard-disk physical limitation.
In this case, I am wondering how could I write it with a higher speed on the ram disk? since its physical limitation is much higher. Could anyone answer me?
Many thanks
답변 (3개)
Walter Roberson
2013년 1월 23일
0 개 추천
If speed during main program execution is the critical factor, then consider writing out the images as binary files using fwrite(), and then at a later time when main program execution is finished, do a pass that fread() and imwrite() them.
댓글 수: 4
Jhen-Si Chen
2013년 1월 23일
Walter Roberson
2013년 1월 24일
You would use this kind of approach when the time required to process the data is greater than the time you have available between samples (frames), but you do not actually need the results of the processing until after all the samples have been collected. A straight fwrite() would probably write out more data than imwrite() but there would be considerably less cpu processing, which can sometimes be critical.
Jhen-Si Chen
2013년 1월 24일
Walter Roberson
2013년 1월 24일
imwrite() needs to do image compression for most image formats.
Jhen-Si Chen
2013년 1월 24일
0 개 추천
댓글 수: 2
Image Analyst
2013년 1월 24일
편집: Image Analyst
2013년 1월 24일
This is not an answer and should have been added to your comment above.
So why don't you write directly to your ramdisk then? Why use the hard disk during image acquisition? Originally you said you tried this, now you're saying you are using imwrite to go to "some buffer maybe in the hard disk" - well, what is the file name in that call to imwrite that you're giving it? Is it a filename on the ramdisk?
Jhen-Si Chen
2013년 1월 24일
Jan
2013년 1월 24일
0 개 추천
When you write 768kB to a hard disk, the data is stored in the RAM also at first, e.g. in the write cache of the harddisk. It is not trivial to measure the time, which is required until the data are written physically to the disk.
댓글 수: 3
Jhen-Si Chen
2013년 1월 24일
Walter Roberson
2013년 1월 24일
No, the above applies when writing to hard disk.
Jan
2013년 1월 24일
@Jhen-Si Chen: No, this means that writing small files, e.g you <1MB file, to a hard disk is at first buffered in DRAM, such that the processor can proceed its work until the slow hard drive has written the data to the disk physically.
Therefore I think that the similarity of 93 MB/s for IMWRITE and 100 MB/s for the hard disk speed is a pure accident. The timing with the RAM disk seems to be a further argument for this claim.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!