4 ms·
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 som
by tombert 4y ago
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.
- giuscri 4y ago`cat /dev/urandom > /tmp/myfile` is faster on macos though
- tombert 4y agoI 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.
- nacs 4y ago`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)
- NoboruWataya 4y agoI 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.
- tombert 4y agoThe 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-than-your-hadoop-cluster.html https://adamdrake.com/command-line-tools-can-be-235x-faster-...