STRA-338 size-fn: tokenizer: bench examples keep every changed line within 120 columns

This commit is contained in:
Pavlo Ratushnyi
2026-11-06 18:49:54 +01:00
parent 3df69b1ebe
commit ebdb35f3cb
2 changed files with 12 additions and 8 deletions
+4 -1
View File
@@ -46,7 +46,10 @@ fn decoded_bytes(tokenizer: &Tokenizer, ids: &[u32]) -> usize {
fn report(text: &str, ids: &[u32], (encode, decode): (Duration, Duration), bytes: usize) {
eprintln!(
"text {} bytes -> {} tokens: encode {:.1} ms ({:.2} Mtok/s); decode_bytes one id at a time {:.2} us/token ({} bytes)",
concat!(
"text {} bytes -> {} tokens: encode {:.1} ms ({:.2} Mtok/s); ",
"decode_bytes one id at a time {:.2} us/token ({} bytes)"
),
text.len(),
ids.len(),
encode.as_secs_f64() * 1e3,
+8 -7
View File
@@ -31,13 +31,14 @@ fn next_turn(text: &str) -> String {
fn report(text: &str, reference: &[u32], ms: [f64; 7]) {
let [reference_ms, fast_ms, first_ms, warm_ms, next_ms, decode_ms, matches_ms] = ms;
let mtok = |ms: f64| reference.len() as f64 / ms / 1e3;
println!(
"{} bytes, {} tokens\n reference (regex + string BPE) {reference_ms:8.2} ms {:6.2} Mtok/s\n fast path, no cache {fast_ms:8.2} ms {:6.2} Mtok/s\n fast path, cache cold {first_ms:8.2} ms\n cache warm (same text) {warm_ms:8.2} ms\n cache warm + new tail {next_ms:8.2} ms\n decode_bytes {decode_ms:8.2} ms\n decodes_to {matches_ms:8.2} ms",
text.len(),
reference.len(),
mtok(reference_ms),
mtok(fast_ms),
);
println!("{} bytes, {} tokens", text.len(), reference.len());
println!(" reference (regex + string BPE) {reference_ms:8.2} ms {:6.2} Mtok/s", mtok(reference_ms));
println!(" fast path, no cache {fast_ms:8.2} ms {:6.2} Mtok/s", mtok(fast_ms));
println!(" fast path, cache cold {first_ms:8.2} ms");
println!(" cache warm (same text) {warm_ms:8.2} ms");
println!(" cache warm + new tail {next_ms:8.2} ms");
println!(" decode_bytes {decode_ms:8.2} ms");
println!(" decodes_to {matches_ms:8.2} ms");
}
fn load(dir: &str) -> Tokenizer {