3

Which command produces more data per second? This could be useful to quickly fill a file with garbage data or to test data transfer rates. So far, I found that "/dev/zero" is the quickest one.

$ cat /dev/urandom | pv > /dev/null
3,04GO 0:08:22 [5,83MB/s] [ <=>                                  ]

$ yes | pv > /dev/null
38GO 0:11:56 [40,2MB/s] [          <=>                        ]

$ cat /dev/zero | pv > /dev/null
754GO 0:08:52 [ 1,4GB/s] [                      <=>             ]

Would you suggest another possible faster command?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
mountrix
  • 141
  • 3
    For me dd if=/dev/zero bs=8192 | pv > /dev/null is giving the best results. – Rui F Ribeiro Oct 26 '16 at 02:00
  • 1
    Just beware that testing data transfer rates with a stream of zeros to a filesystem that compresses data - such as BTRFS or ZFS (among others) - will product wildly inaccurate results as a stream of identical values compresses really well. – Andrew Henle Oct 26 '16 at 10:46
  • @RuiFRibeiro In my case I got 2.84GB/s with your command versus 3.2 GB/s with cat. But by tunning "bs" I got almost the same (40k for me). – mountrix Oct 26 '16 at 20:59
  • @AndrewHenle Good point! – mountrix Oct 26 '16 at 20:59

2 Answers2

3

The system interprets /dev/zero as literally just an endless stream of zeroes, and I believe this is the fastest way to obtain useless information. In all likelihood, you're going to be bottlenecked by your physical disk speed, and so this should be as fast as you'd ever need even if there are any faster methods.

Also, when testing, I was surprised to find that cat was much faster than dd for this!

  • I did not thought about dd, but looking for it, cat could sometimes be faster than dd. I guess it is dependent on the implementation. – mountrix Oct 26 '16 at 20:58
  • At least on my system, which is Xubuntu and EXT4, cat is faster than dd. Like you, I also got ~10% slower with Rui F Ribeiro's dd command. – Aaron Franke Oct 26 '16 at 22:17
0

try

pv /dev/zero >/dev/null
  • This one is much faster (by a factor of 10), but still I was looking for a command producing data for a file. If you redirect this command to a file, it won't be as fast as you can see executing: pv /dev/zero | pv. Anyway thank you for this idea and welcome to stackexchange! – mountrix Sep 04 '17 at 20:17