How come POSIX write is so fast?

How come POSIX write is so fast?

Other urls found in this thread:

lotr.wikia.com/wiki/Radagast
lotr.wikia.com/wiki/Lothlórien
git.savannah.gnu.org/cgit/coreutils.git/tree/src/yes.c
github.com/openbsd/src/blob/master/usr.bin/yes/yes.c
bxr.su/OpenBSD/bin/echo/echo.c
bxr.su/DragonFly/bin/echo/echo.c
bxr.su/NetBSD/bin/echo/echo.c
bxr.su/FreeBSD/bin/echo/echo.c
git.savannah.gnu.org/cgit/coreutils.git/tree/src/echo.c
twitter.com/SFWRedditVideos

...

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?

lotr.wikia.com/wiki/Radagast
lotr.wikia.com/wiki/Lothlórien

funnily it does, I expected to be ~5% slower but it actually outperforms GNU can

>no source

>nim

git.savannah.gnu.org/cgit/coreutils.git/tree/src/yes.c
holy fuck

#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...

kek github.com/openbsd/src/blob/master/usr.bin/yes/yes.c

I will just leave this here

bxr.su/OpenBSD/bin/echo/echo.c
bxr.su/DragonFly/bin/echo/echo.c
bxr.su/NetBSD/bin/echo/echo.c
bxr.su/FreeBSD/bin/echo/echo.c
git.savannah.gnu.org/cgit/coreutils.git/tree/src/echo.c

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