0

I am using Intel Atom D525, an extremely unpowerful processor for my family router with Debian 9. I tried both curl http://dl.google.com/dl/android/aosp/sailfish-pq2a.190205.003-factory-164a7269.zip > dev/null and curl http://dl.google.com/dl/android/aosp/sailfish-pq2a.190205.003-factory-164a7269.zip -o dev/null on that. The previous one can only get a speed of 25 MB/s and the next one can get a speed of 38 MB/s, mostly full of my 300Mbps bandwidth. Why these two command have such a gap of performance?

  • 2
    I'm commenting rather than answering because this is pure hypothesis, but I suspect that explicitly telling curl via -o /dev/null behaves more efficiently under-the-hood rather than having the shell redirect the output of curl "by hand" into /dev/null. In the first case, curl's output is explicitly sent to null, while in the second, curl writes to stdout, and that is redirected externally from curl. – DopeGhoti Feb 6 at 16:08
  • I do wonder a bit about the use-case here. Are you just measuring your network connection speed? Otherwise one would assume that it would be more interesting to look at how quickly you can download and process/store the file, than just download and throw away. – ilkkachu Feb 6 at 17:49
  • @ilkkachu If I use wget, the speed is about 8 MB/s. With curl >, the speed is about 11 MB/s. With curl -o, the speed is about 14 MB/s. – Steven Yang Feb 7 at 2:22
2

I can't reproduce this.

For that particular file, I did get slower speeds on some of the attempts, but that had nothing to do with the arguments to curl, it happened randomly and with both variants.

The version of curl I have (curl 7.52.1 (x86_64-pc-linux-gnu), from Debian), also doesn't handle /dev/null any differently from other output files, strace shows an open() and write()s to it:

$ strace -etrace=open,write curl -s http://www.google.com/ -o /dev/null
[...]
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
write(4, "<!doctype html><html itemscope=\""..., 4096) = 4096
write(4, "px 0 4px;margin-left:4px}input{f"..., 4096) = 4096
...
+++ exited with 0 +++

Here's an output for my last two runs, no significant difference between the > /dev/null and -o /dev/null:

$ curl http://dl.google.com/dl/android/aosp/sailfish-pq2a.190205.003-factory-164a7269.zip > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1344M  100 1344M    0     0  94.5M      0  0:00:14  0:00:14 --:--:-- 91.0M

$ curl http://dl.google.com/dl/android/aosp/sailfish-pq2a.190205.003-factory-164a7269.zip -o /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1344M  100 1344M    0     0  89.3M      0  0:00:15  0:00:15 --:--:-- 92.8M
  • There are also no differences for the two commands on my PC with Intel i7. But on devices with much slower CPU I can always reproduce this. – Steven Yang Feb 7 at 2:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.