Sha256: dfe644035cad6ff13b280e3d72c9df2569491ecddc84f7c2502daf940814a63e

Contents?: true

Size: 773 Bytes

Versions: 4

Compression:

Stored size: 773 Bytes

Contents

//! Compare `insert` and `insert_unique_unchecked` operations performance.

#![feature(test)]

extern crate test;

use hashbrown::HashMap;
use test::Bencher;

#[bench]
fn insert(b: &mut Bencher) {
    let keys: Vec<String> = (0..1000).map(|i| format!("xxxx{}yyyy", i)).collect();
    b.iter(|| {
        let mut m = HashMap::with_capacity(1000);
        for k in &keys {
            m.insert(k, k);
        }
        m
    });
}

#[bench]
fn insert_unique_unchecked(b: &mut Bencher) {
    let keys: Vec<String> = (0..1000).map(|i| format!("xxxx{}yyyy", i)).collect();
    b.iter(|| {
        let mut m = HashMap::with_capacity(1000);
        for k in &keys {
            unsafe {
                m.insert_unique_unchecked(k, k);
            }
        }
        m
    });
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/hashbrown-0.15.2/benches/insert_unique_unchecked.rs
wasmtime-28.0.0 ./ext/cargo-vendor/hashbrown-0.15.2/benches/insert_unique_unchecked.rs
wasmtime-27.0.0 ./ext/cargo-vendor/hashbrown-0.15.1/benches/insert_unique_unchecked.rs
wasmtime-26.0.0 ./ext/cargo-vendor/hashbrown-0.15.0/benches/insert_unique_unchecked.rs