hexdump performance test, part 1

spoiler alert: it's slow as molasses

part 2 will be presented at a later date

(yes, please don't fill 8GB of memory with
random data and hexdump it)

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-29 13:23:31 +01:00
parent cec3de5c9e
commit b70ee41c5c
3 changed files with 24 additions and 6 deletions
+4 -3
View File
@@ -18,6 +18,7 @@ main(int argc, char **argv)
{
int same = 0;
char *buf;
size_t size = 8589934592;
(void) argc, (void) argv;
(void) errhook(exit_cleanup);
@@ -26,12 +27,12 @@ main(int argc, char **argv)
/* https://man.openbsd.org/pledge.2 */
xpledgex("stdio", NULL);
buf = rmalloc(BUFSIZ);
if (!memcmp(buf, buf + (BUFSIZ >> 1), BUFSIZ >> 1))
buf = rmalloc(size);
if (!memcmp(buf, buf + (size >> 1), size >> 1))
same = 1;
if (argc < 2) /* no spew */
spew_hex(buf, BUFSIZ);
spew_hex(buf, size);
free_and_set_null(&buf);
fprintf(stderr, "\n%s\n", same ? "You win!" : "You lose!");