-
-
Save dnbaker/1256ef4aefafe23a4a95cdf2cdb42a48 to your computer and use it in GitHub Desktop.
Very fast yes command (4x as fast as gnu coreutils)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdio> | |
| #include <cstring> | |
| #include <string> | |
| #include "unistd.h" | |
| #ifndef _BUF_SZ__ | |
| #define _BUF_SZ__ 1 << 16 | |
| #endif | |
| int main(int argc, char *argv[]) { | |
| const char *val(argc > 1 ? argv[1]: "y"); | |
| std::string data; | |
| while(data.size() + std::strlen(val) < _BUF_SZ__) data += val, data += '\n'; | |
| while(write(STDOUT_FILENO, data.data(), data.size())); | |
| return EXIT_FAILURE; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment