How come POSIX write is so fast?
How come POSIX write is so fast?
Other urls found in this thread:
lotr.wikia.com
lotr.wikia.com
git.savannah.gnu.org
github.com
bxr.su
bxr.su
bxr.su
bxr.su
git.savannah.gnu.org
twitter.com
...
what's enough to write fast yes command:
- calculate lcm of phrase length and 4096 (page size)
- allocate buffer with that size and fill it
- raw write that buffer in loop
simple, right? it doesn't need to be ugly gargantuan mess like GNU yes
I'm trying to figure that one out right now
Radagast @ lothlorien ?
Lol jesus
Is that any faster than GNU yes?
funnily it does, I expected to be ~5% slower but it actually outperforms GNU can
>no source
>nim
#include
#include
std::string repeat(const std::string &word, int times) {
std::string result;
result.reserve(times * word.length());
for (int a = 0; a < times; a++)
result += word;
return result;
}
int main() {
std::string s = repeat("y\n", 4096 * 8);
for (;;)
std::cout
>implying you could write something better
get out
#define ever ;;
for(ever)
std::cout
don't take my spider face loop away faggot
OP did
busybox did
#include "libbb.h"
int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int yes_main(int argc UNUSED_PARAM, char **argv)
{
char **pp;
argv[0] = (char*)"y";
if (argv[1])
++argv;
do {
pp = argv;
while (1) {
fputs(*pp, stdout);
if (!*++pp)
break;
putchar(' ');
}
} while (putchar('\n') != EOF);
bb_perror_nomsg_and_die();
}
plan 9 did
while() { echo y }
and Plan 9 outputs few MB/s, not GB/s
why exactly does this need to be fast?
I feel like I'm missing something here
and you really need a few b/s
write from C is even faster
const char *s = repeat("y\n", 4096 * 8).c_str();
for (;;)
write(1, s, 4096*8);
yeah, remember when this tool was for automating the dialogs?
There's no reason why it shouldn't be simple and fast.
behold the 9brainlet, whose puny subhuman mind is oppressed by the "complexity" of real programs so much he prefers to use the feeble powerless "simple n suckless" soyware that his retarded excuse of a """brain""" can understand...
it's unbuffered, writes directly to fd as fast as fd can accept data. Also works in Windows (old XENIX call, _write)
virgin BSDDies vs chad POSIXLY_CORRECT