The following simple program is 100x
faster when directed to /dev/null
:
#include <stdio.h>
int main(int argc, char **argv)
{
for (int i=0;i<10000000;i++) { printf("%d\n",i); }
return 0;
}
How can I find where exactly the speedup comes from?
$ gcc -O0 main.c -o main
$ ./main
$ ./main >/dev/null
$ ./main > output.txt
EDIT:
redirecting to a file is 100x
faster too.
so I guess /dev/null
is exactly like any other file?