2020-01-09 at 4:20 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 4:45 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 4:53 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 4:57 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 5:03 AM UTC
aldra
JIDF Controlled Opposition
why are you making a list of all possible ipv4 addresses
you could use subnet notation to pass a range anywhere you might need to
2020-01-09 at 5:05 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 5:10 AM UTC
aldra
JIDF Controlled Opposition
for(a=0;a<255;a++)
{
for(b=0;b<255;b++)
{
for(c=0;c<255;c++)
{
for(d=0;d<255;d++)
{
address="$a.$b.$c.$d";
print(address);
}
}
}
}
or something
The following users say it would be alright if the author of this
post didn't die in a fire!
2020-01-09 at 5:10 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 5:12 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 6:08 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 6:52 AM UTC
This post has been edited by a bot I made to preserve my privacy.
2020-01-09 at 9:36 AM UTC
This was the fastest I managed to get:
#define buflines 2048
int main() {
char *lu = malloc(3*256+1);
for (int k=0; k<256; k++) {
sprintf(lu+(k*3), "%03d", k);
}
lu[3*256+1] = '\0';
char *buf = malloc(buflines * 16 + 1);
for (int k = 0; k < buflines; k++) {
buf[k*16 + 3] = '.';
buf[k*16 + 7] = '.';
buf[k*16 + 11] = '.';
buf[k*16 + 15] = '\n';
}
int p;
char *bufp;
unsigned int i = 1 << 24;
while (i) {
bufp = buf;
for (int k = 0; k < buflines; k++) {
p = ((i & 0xff000000) >> 24) * 3;
bufp[0] = *(lu+p);
bufp[1] = *(lu+p+1);
bufp[2] = *(lu+p+2);
p = ((i & 0xff0000) >> 16) * 3;
bufp[4] = *(lu+p);
bufp[5] = *(lu+p+1);
bufp[6] = *(lu+p+2);
p = ((i & 0xff00) >> 8) * 3;
bufp[8] = *(lu+p);
bufp[9] = *(lu+p+1);
bufp[10] = *(lu+p+2);
p = (i & 0xff) * 3;
bufp[12] = *(lu+p);
bufp[13] = *(lu+p+1);
bufp[14] = *(lu+p+2);
bufp += 16;
i--;
}
//printf("%s", buf);
write(1, buf, buflines * 16);
}
return 0;
}
[lanny:~/killme]$ time ./a.out > /dev/null
./a.out > /dev/null 0.07s user 0.00s system 97% cpu 0.081 total
16 million lines in ~0.5 seconds cold, ~0.08 on the second run. Interestingly `printf("%s", buf)` outperforms a direct write which surprised me, but I'm guessing printf has some buffering going on because when I added the internal buffer it got a lot faster.
The following users say it would be alright if the author of this
post didn't die in a fire!
2020-01-09 at 10:05 AM UTC
aldra
JIDF Controlled Opposition
lol I was just going to say don't perform the write for each line
is the original code sh? I can't tell
2020-01-09 at 10:24 AM UTC
Yee, or zsh, but I think it's all bash-compatible. No idea about classic borne.