News for hackers. Stuff that matters.
Re:A little story about the `yes` Unix command by tombert on Thursday July 21, 2022 @03:46AM (#32176818)
It always amazed me how fast “yes” is. Whenever I need to generate a really big file for whatever reason (e.g. testing multipart file uploads), I will run something like “yes > myfile.txt” for a few seconds.

Similarly, I tried writing a naive version in node.JS a few years ago and it was several orders of magnitude slower than coreutils…, which is usually the case whenever I try and clone one of the “simple” utilities from coreutils.

Re:A little story about the `yes` Unix command by NoboruWataya on Thursday July 21, 2022 @07:27AM (#32178086)
I just tried "yes > myfile.txt" for a few seconds (less than five) and then checked the size. 1.4 billion lines! I knew yes was fast but that's pretty mind-blowing.
Re:A little story about the `yes` Unix command by tombert on Thursday July 21, 2022 @10:56AM (#32180156)
The GNU coreutils never fail to impress me with how insanely fast they go. One of my favorite blog posts of all time [1] really opened my eyes to how insanely optimized Unix really is.

[1] https://adamdrake.com/command-line-tools-can-be-235x-faster-...

Re:A little story about the `yes` Unix command by giuscri on Thursday July 21, 2022 @05:40AM (#32177358)
`cat /dev/urandom > /tmp/myfile` is faster on macos though
Re:A little story about the `yes` Unix command by nacs on Thursday July 21, 2022 @11:44AM (#32180745)
`yes` is far faster on my Linux (2.2GB/s) vs /dev/urandom (0.38GB/s) -- not surprising since the `man` page for urandom says:

"[urandom] is designed for security, not speed, and is poorly suited to generating large amounts of random data"

`cat /dev/zero` is pretty much as fast as `yes` on my system however (2.1GB/s)

Re:A little story about the `yes` Unix command by tombert on Thursday July 21, 2022 @07:24AM (#32178059)
I suspect that just doing a `truncate` command is probably even faster. I just like the `yes` version because it requires basically zero thought on my end.