diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-06-11 12:03:10 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-06-11 12:03:10 -0700 |
commit | ecd0edf168fd1a2ff275f08b2daa7ea6926c623e (patch) | |
tree | 385a57175539dc2944a8db49b01dde4206cfed75 /tests/fasta.cpp | |
parent | baf8505096e4bdaf3bb5d9794bb1edca29a19463 (diff) |
improve fasta benchmark
Diffstat (limited to 'tests/fasta.cpp')
-rw-r--r-- | tests/fasta.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/fasta.cpp b/tests/fasta.cpp index 7954feef..35bd4425 100644 --- a/tests/fasta.cpp +++ b/tests/fasta.cpp @@ -7,6 +7,24 @@ #include <stdlib.h> #include <string.h> +// limit output, so we do not benchmark speed of printing +void puts_limited(char *x) +{ + static int left = 550; + int len = strlen(x); + if (len <= left) { + puts(x); + left -= len; + return; + } + if (left > 0) { + x[left] = '\0'; + puts(x); + x[left] = 'z'; + left = 0; + } +} + struct Random { enum { IM = 139968, IA = 3877, IC = 29573 }; Random() : last(42) {} @@ -68,7 +86,7 @@ struct LineBuffer { lastN = N + 1; return *this; } - void writeline() { puts(buffer); } + void writeline() { puts_limited(buffer); } protected: char buffer[lineLength + 2]; size_t lastN; @@ -87,7 +105,7 @@ struct RotatingString { memcpy(temp, buffer + pos, bytes); temp[bytes] = '\n'; temp[bytes] = '\0'; - puts(temp); + puts_limited(temp); delete temp; pos += bytes; if ( pos > size ) |