Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions benches/programs/string_index_ascii.ndc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 10,000 reads near the end of a 131,072-codepoint ASCII string.
// Build by doubling so construction is small compared with O(n) indexing.
let text = "abcd";
for _ in 0..15 {
text <>= text;
}
let last = text.len - 1;
let matches = 0;
for i in 0..10_000 {
if text[last - i % 4] == "d" {
matches += 1;
}
}
assert_eq(matches, 2_500);
print(matches);
15 changes: 15 additions & 0 deletions benches/programs/string_index_unicode.ndc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Same codepoint count and access pattern as string_index_ascii.ndc,
// with a mix of 1-, 2-, 3-, and 4-byte UTF-8 codepoints.
let text = "aé中😀";
for _ in 0..15 {
text <>= text;
}
let last = text.len - 1;
let matches = 0;
for i in 0..10_000 {
if text[last - i % 4] == "😀" {
matches += 1;
}
}
assert_eq(matches, 2_500);
print(matches);
Loading