Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/accessible/tests/mochitest/events/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quelle  bench.rs

  Sprache: Rust
 

// Any copyright to the test code below is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

use criterion::black_box;
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use mapped_hyph::Hyphenator;
use std::fs;

const SAMPLE_SIZE: usize = 300;
const DIC_PATH: &str = "hyph_en_US.hyf";

fn bench_construct(c: &mut Criterion) {
    c.bench_function("construct", |b| {
        b.iter(|| {
            let dic = unsafe { mapped_hyph::load_file(DIC_PATH) }
                .expect(&format!("failed to load dictionary {}", DIC_PATH));
            let _ = Hyphenator::new(black_box(&*dic));
        })
    });
}

fn bench_find_hyphen_values(c: &mut Criterion) {
    // XXX: Should we copy this file to the crate to ensure reproducability?
    let data = fs::read_to_string("/usr/share/dict/words").expect("File reading failed.");
    let words: Vec<&str> = data.lines().take(SAMPLE_SIZE).collect();

    let dic = unsafe { mapped_hyph::load_file(DIC_PATH) }
        .expect(&format!("failed to load dictionary {}", DIC_PATH));
    let hyph = Hyphenator::new(&*dic);

    c.bench_with_input(
        BenchmarkId::new("bench_word", SAMPLE_SIZE),
        &words,
        |b, words| {
            b.iter(|| {
                let mut values: Vec<u8> = vec![01000];
                for w in words {
                    hyph.find_hyphen_values(&w, &mut values);
                }
            });
        },
    );
}

criterion_group!(benches, bench_construct, bench_find_hyphen_values,);
criterion_main!(benches);

Messung V0.5 in Prozent
C=85 H=84 G=84

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-18) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.