mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Reduce GNU Make latency 17% for cosmo
fgets() is now 4x faster which makes Make 2% faster. Landlock Make now has a builtin $(uniq ...) function that uses critbit trees rather than functional programming. Since uniq is the most important function this optimization makes our cold start latency 15% faster.
This commit is contained in:
parent
8835b82a7c
commit
d76dfadc7a
7 changed files with 96 additions and 11 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/hyperion.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
|
@ -31,3 +32,19 @@ TEST(fgets, test) {
|
|||
ASSERT_STREQ("John Keats\n", fgets(buf, sizeof(buf), f));
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void Benchmark(void) {
|
||||
FILE *f;
|
||||
char *line;
|
||||
char buf[512];
|
||||
f = fmemopen(gc(strdup(kHyperion)), kHyperionSize, "r+");
|
||||
for (;;) {
|
||||
line = fgets(buf, sizeof(buf), f);
|
||||
if (!line) break;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
BENCH(fgets, bench) {
|
||||
EZBENCH2("fgets", donothing, Benchmark());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue