[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>decide to test random things with pv >gnu yes is fucking

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 6
Thread images: 1

>decide to test random things with pv
>gnu yes is fucking retardedly fast (~6GiB/s) given how completely BLOAT the source code looks
>3 levels of header autism to obfuscate a fucking write() call
>try naively writing my own yes
>hella slow (~100MiB/s)
>copy random BSD and Sun yes.c's
>virtually the same as mine.

wtf /g/, I thought bloat was bad.
>>
>>60877367
autism thread?
BITS 64
CPU X64

global _start
section .text
_start:
inc rdi ; stdout, will not change after syscall
mov rsi, y ; will not change after syscall
mov rdx, 8192 ; will not change after syscall
_loop:
mov rax, 1 ; sys_write
syscall
jmp _loop

y: times 4096 db "y", 0xA

autism thread.
>>
>>60877395
it doesn't work

$ ./a.out test
y
y
y
y
y


it only outputs y
>>
>>60877418
that's the point
fix it yourself if you want arguments
>>
>>60877429
whatever I think i figured it out

// adjust to fit the file descriptor buffering in your kernel
#define TOTAL 32768

// output y\n as fast as possible to stdout
// or output whatever string the user provides
int main(int argc, char* argv[]) {

// remove calling name
argc--; argv++;

// default values
size_t LEN = 2;
char* yes = "y\n";

// handle args
if (argc > 0) {
// TOTAL less one for space for \n
LEN = strnlen(argv[0], TOTAL-1) + 1;
yes = argv[0]; // new string
// we don't need a \0 anyhow
yes[LEN-1] = '\n';
}

// alloc buffer with zeros statically
char buf[TOTAL] = { 0 };
// track location in buffer
size_t bufused = 0;

// copy string to fill buffer
while (bufused+LEN <= TOTAL) {
memcpy(buf+bufused, yes, LEN);
bufused += LEN;
}

// print forever bro
while (write(1, buf, bufused) == bufused) {}
// tf bro
return 1;
}


I guess stdio is just shit.
>>
>>60877470
└─> ./muh-yes-muhfugga | pv >/dev/null 
^C.6GiB 0:00:04 [6.76GiB/s] [ <=> ]


how underwhelming...I thought it was some weird gnu magic.
Thread posts: 6
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.