mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
Tests: Benchmark DisjointChunck::is_empty
This commit is contained in:
parent
3a177b9209
commit
44a6d7968a
Notes:
sideshowbarker
2024-07-18 02:47:59 +09:00
Author: https://github.com/mhermier Commit: https://github.com/SerenityOS/serenity/commit/44a6d7968a0 Pull-request: https://github.com/SerenityOS/serenity/pull/11361
1 changed files with 56 additions and 0 deletions
|
@ -80,3 +80,59 @@ TEST_CASE(spans)
|
|||
|
||||
EXPECT_EQ(it, cross_chunk_slice.end());
|
||||
}
|
||||
|
||||
#define INIT_ITERATIONS (1'000'000)
|
||||
#define ITERATIONS (100)
|
||||
|
||||
static DisjointChunks<int> basic_really_empty_chunks;
|
||||
|
||||
BENCHMARK_CASE(basic_really_empty)
|
||||
{
|
||||
DisjointChunks<int> chunks;
|
||||
for (size_t i = 0; i < ITERATIONS; ++i)
|
||||
EXPECT(chunks.is_empty());
|
||||
}
|
||||
|
||||
static DisjointChunks<int> basic_really_empty_large_chunks = []() {
|
||||
DisjointChunks<int> chunks;
|
||||
chunks.ensure_capacity(INIT_ITERATIONS);
|
||||
for (size_t i = 0; i < INIT_ITERATIONS; ++i)
|
||||
chunks.append({});
|
||||
return chunks;
|
||||
}();
|
||||
|
||||
BENCHMARK_CASE(basic_really_empty_large)
|
||||
{
|
||||
for (size_t i = 0; i < ITERATIONS; ++i)
|
||||
EXPECT(basic_really_empty_large_chunks.is_empty());
|
||||
}
|
||||
|
||||
static DisjointChunks<int> basic_mostly_empty_chunks = []() {
|
||||
DisjointChunks<int> chunks;
|
||||
chunks.ensure_capacity(INIT_ITERATIONS + 1);
|
||||
for (size_t i = 0; i < INIT_ITERATIONS; ++i)
|
||||
chunks.append({});
|
||||
chunks.append({ 1, 2, 3 });
|
||||
return chunks;
|
||||
}();
|
||||
|
||||
BENCHMARK_CASE(basic_mostly_empty)
|
||||
{
|
||||
for (size_t i = 0; i < ITERATIONS; ++i) {
|
||||
EXPECT(!basic_mostly_empty_chunks.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
static DisjointChunks<int> basic_full_chunks = []() {
|
||||
DisjointChunks<int> chunks;
|
||||
chunks.ensure_capacity(INIT_ITERATIONS + 1);
|
||||
for (size_t i = 0; i < INIT_ITERATIONS; ++i)
|
||||
chunks.append({ 1, 2, 3 });
|
||||
return chunks;
|
||||
}();
|
||||
|
||||
BENCHMARK_CASE(basic_full)
|
||||
{
|
||||
for (size_t i = 0; i < ITERATIONS; ++i)
|
||||
EXPECT(!basic_full_chunks.is_empty());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue