mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
Notes:
sideshowbarker
2024-07-19 12:54:08 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3eb1a7f8f88
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)
|
||||
|
Loading…
Reference in New Issue
Block a user