I am writing some code to create a Bitmap, do some drawing and then saving to file. Below is a simplified version:
FinalImage = new System.Drawing.Bitmap(FinalImageWidth, FinalImageHeight);
Pencil = Graphics.FromImage(FinalImage);
Pencil.Clear(Color.White);
Pencil.DrawImage(image,x,y);
FinalImage.Save(FinalImageSaveLocation + "test" + Counter + ".bmp");
This is fine.
Out of interest I timed this creation process over 100 times writing to C:\ and it came up as 2secs, I then plugged in a USB Pen drive and wrote 100 image to that and it took 5.5secs.
I thought flash drives were faster although I know different pen drives have different capabilities and guess there is on-board USB controllers and Cache to take into account. Am I missing something?
Thanks
As a relative test between two filesystems, that should be fine. As for why the USB drive appears to be slower there could be a number of reasons. Perhaps that particular drive uses slower flash memory. Perhaps the USB interface is only running at 12 Mbps (“Full Speed”) instead of at USB 2.0 speeds. Perhaps the OS is using an in-memory write-back cache for the HDD that is preventing you from seeing the actual performance of the disk.
As a benchmark of absolute write speed, however, your test may not be very accurate. Creating and drawing a bitmapped image in memory is a CPU and memory-intensive task, and so your absolute performance values may be skewed by the performance (or lack thereof) of the processor and memory subsystems, causing inconsistent results across multiple platforms. A slightly better approach might be to zero-out a 1 KB block of memory, open a random file on the device you want to test, and then time how long it takes to write your 1 KB block 10,000 times to that device.