This results in a noticeable increase in performance:
$ yes /dev/null | head -n
10000000 | tr '\n' '\0' \
| time --format=%E ./src/du-prev -l --files0-from=- > /dev/null
0:20.40
$ yes /dev/null | head -n
10000000 | tr '\n' '\0' \
| time --format=%E ./src/du -l --files0-from=- > /dev/null
0:16.57
* src/du.c (print_size): Prefer putchar and fputs which may be unlocked
unlike printf. Prefer ferror to fflush.
fputs (timetostr (pdui->tmax.tv_sec, buf), stdout);
}
}
- printf ("\t%s%c", string, opt_nul_terminate_output ? '\0' : '\n');
- if (fflush (stdout) != 0)
+ putchar ('\t');
+ fputs (string, stdout);
+ putchar (opt_nul_terminate_output ? '\0' : '\n');
+ if (ferror (stdout))
write_error ();
-
}
/* Fill the di_mnt set with local mount point dev/ino pairs. */