AK: Add a benchmark for parsing 4chan catalog JSON

I was able to get parsing time down to about 1/3 of the original time
by using callgrind+kcachegrind. There's definitely more improvements
that can be made here, but I'm gonna be happy with this for now. :^)
This commit is contained in:
Andreas Kling 2019-08-04 11:57:32 +02:00
parent b62a12c687
commit 3eb1a7f8f8
Notes: sideshowbarker 2024-07-19 12:54:08 +09:00
2 changed files with 24 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -43,4 +43,27 @@ TEST_CASE(load_form)
});
}
BENCHMARK_CASE(load_4chan_catalog)
{
FILE* fp = fopen("4chan_catalog.json", "r");
ASSERT(fp);
StringBuilder builder;
for (;;) {
char buffer[1024];
if (!fgets(buffer, sizeof(buffer), fp))
break;
builder.append(buffer);
}
fclose(fp);
auto json_string = builder.to_string();
for (int i = 0; i < 10; ++i) {
JsonValue form_json = JsonValue::from_string(json_string);
EXPECT(form_json.is_array());
}
}
TEST_MAIN(JSON)