Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Benchmarking

Litsea includes a Criterion benchmark suite for measuring performance.

Running Benchmarks

cargo bench --bench bench

Or via the Makefile:

make bench

Benchmark Suite

The benchmarks are defined in litsea/benches/bench.rs:

BenchmarkDescription
segment_short/adaboost/{ja,zh,ko}Segment a short sentence (AdaBoost)
segment_short/averaged_perceptron/{ja,zh,ko}Segment + POS tag a short sentence
segment_long_japanese/{adaboost,averaged_perceptron}Process the full Bocchan novel (~300 KB)
get_type_hiraganaCharacter type classification
add_corpusCorpus ingestion for training
predict_adaboostSingle AdaBoost prediction

Models are loaded synchronously with load_model_from_path — no async runtime is involved in the benchmarks.

HTML Reports

Criterion generates detailed HTML reports with statistics and comparison graphs at:

target/criterion/report/index.html

Open this file in a browser after running benchmarks to view:

  • Iteration times with confidence intervals
  • Throughput measurements
  • Comparison with previous runs (automatic regression detection)

Interpreting Results

Key performance factors:

  • Segmentation is linear in input length (O(n))
  • Character classification is a direct match on character ranges (a few nanoseconds; no setup cost)
  • Prediction at each position depends on the number of features (38-42, constant)
  • Model loading time is proportional to the model file size