mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
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:
parent
b62a12c687
commit
3eb1a7f8f8
2 changed files with 24 additions and 0 deletions
1
AK/Tests/4chan_catalog.json
Normal file
1
AK/Tests/4chan_catalog.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -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)
|
TEST_MAIN(JSON)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue