From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring file transfer speed from USB to PC's HDD

Hello everyone,


I want to measure data transfer speed in Mbps. The data are 50mb, 100mb and 1gb. I want to measure the speed while is coping form USB 2.0 flash drive to my computer HDD. So, I found a topic which can be solution to my problem and understand the calculation. The topic is, https://forums.ni.com/t5/Example-Programs/File-Transfer-with-Progress-Bar-Using-LabVIEW/ta-p/3507951

 

You can find my labview program at the attachment.

 

The problem is I want to make transfer 3 or more times to calculate more accurate average speed. However, I guess the first calculation(first loop) is correct but, after first transfer the transfer is made too fast. Do anyone know the problem cause? or help me to deal with that problem?

0 Kudos
Message 1 of 8
(3,187 Views)

The operating system probably caches the data, so, when any additional copy is run, data are caught from RAM and no actual transfer occurs.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 8
(3,176 Views)

I agree with pincpanter Windows by default cashes both disk reads and disk writes.

 

I am betting there is a way to turn off both read and write caching using the LabVIEW Windows Registry primitives. Just remember to turn it back on at the end of your program.

 

Also a note on your code... Why do you have the huge Flat Sequence? You need to understand DATA FLOW 

 

Do this and your program will operate exactly the same.

111Capture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 8
(3,153 Views)

I made a very quick search and I found no way to disable caching in disk reading. Disabling write caching can improve performance at the expense of some risk of disk corruption. But what's the point in disabling read caching? You would gain no big advantage.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 4 of 8
(3,147 Views)

When testing 3 times, just create three new files.  Windows can only cache what it has already written.  If you make three new files eacht ime (after each run you can delete the files if you want) then it can't cache anything.

 

I also ran into this issue before.  Note: You can abuse this to make reading and writing much faster under controlled conditions......

0 Kudos
Message 5 of 8
(3,143 Views)

@pincpanter wrote:

I made a very quick search and I found no way to disable caching in disk reading. Disabling write caching can improve performance at the expense of some risk of disk corruption. But what's the point in disabling read caching? You would gain no big advantage.


Read and write caching will give you false results as you are not actually reading or writing directly to the disk.

 

You are writing to the cache and when the cache is full or the system is idle the data is written to the disk. When reading the same data from the disk you only read it directly from the disk once or twice after that the data is stored in a cache so you are reading it from RAM not the disk.

 

BTW: I have never heard of any reason disabling write caching could lead to corruption. If anything using write caching on removable drives has a higher chance of corruption as it is possible to remove the drive before all the data is written from the cache to the disk. 

 


HKLM\SYSTEM\CurrentControlSet\Enum\IDE\Diskxxxxxxxxxxxx\DeviceParameters\Disk
Key : UserWriteCacheSetting

 

where xxxxxxx is manufacturer information.

 

See also: https://msdn.microsoft.com/en-us/library/aa965240.aspx

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 8
(3,138 Views)

@RTSLVU  ha scritto:

@pincpanter wrote:

I made a very quick search and I found no way to disable caching in disk reading. Disabling write caching can improve performance at the expense of some risk of disk corruption. But what's the point in disabling read caching? You would gain no big advantage.


Read and write caching will give you false results as you are not actually reading or writing directly to the disk.

 

You are writing to the cache and when the cache is full or the system is idle the data is written to the disk. When reading the same data from the disk you only read it directly from the disk once or twice after that the data is stored in a cache so you are reading it from RAM not the disk.

 

BTW: I have never heard of any reason disabling write caching could lead to corruption. If anything using write caching on removable drives has a higher chance of corruption as it is possible to remove the drive before all the data is written from the cache to the disk. 

 


HKLM\SYSTEM\CurrentControlSet\Enum\IDE\Diskxxxxxxxxxxxx\DeviceParameters\Disk
Key : UserWriteCacheSetting

 

where xxxxxxx is manufacturer information.

 

See also: https://msdn.microsoft.com/en-us/library/aa965240.aspx


Thank you for pointing out my mistake. I read documentation too hastily.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 8
(3,131 Views)

In addition to what was already explained, there is also the issue where the throughput will be much higher if reading and writing contiguous sectors than reading from scattered sectors, because you are also inadvertently testing seek time, also.  (Obviously this doesn't apply to flash drives.)

 

That's why most benchmarking tools have all sorts of different ways to test hard drive throughput.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 8
(3,124 Views)