<commit_before>#![cfg(feature = "nightly")]
#![feature(test)]

extern crate test;
extern crate delta_l as dl;

use std::io::{Write, Seek, SeekFrom, Result};

const TEST_DATA: &'static[u8] = include_bytes!("../test_data/bench.txt");
const TEST_DATA_DELTA: &'static[u8] = include_bytes!("../test_data/bench.txt.delta");

#[derive(Default, Debug, Clone)]
struct SeekableSink(());

impl Write for SeekableSink {
    #[inline]
    fn write(&mut self, buf: &[u8]) -> Result<usize> { Ok(buf.len()) }
    #[inline]
    fn flush(&mut self) -> Result<()> { Ok(()) }
}

impl Seek for SeekableSink {
    fn seek(&mut self, _: SeekFrom) -> Result<u64> {
        Ok(0)
    }
}

#[bench]
fn encrypt(b: &mut test::Bencher){
    b.iter(|| test::black_box(dl::encode_with_checksum([0; 8], &mut TEST_DATA, &mut SeekableSink::default())).unwrap());
}

#[bench]
fn decrypt(b: &mut test::Bencher){
    b.iter(|| test::black_box(dl::decode([0; 8], &mut TEST_DATA_DELTA, &mut SeekableSink::default())).unwrap());
}
<commit_msg>Add checksum-less benches<commit_after>#![cfg(feature = "nightly")]
#![feature(test)]

extern crate test;
extern crate delta_l as dl;

use std::io::{Write, Seek, SeekFrom, Result};

const TEST_DATA: &'static[u8] = include_bytes!("../test_data/bench.txt");
const TEST_DATA_DELTA: &'static[u8] = include_bytes!("../test_data/bench.txt.delta");
const TEST_DATA_DELTA_NOC: &'static[u8] = include_bytes!("../test_data/bench.txt.delta-noc");

#[derive(Default, Debug, Clone)]
struct SeekableSink(());

impl Write for SeekableSink {
    #[inline]
    fn write(&mut self, buf: &[u8]) -> Result<usize> { Ok(buf.len()) }
    #[inline]
    fn flush(&mut self) -> Result<()> { Ok(()) }
}

impl Seek for SeekableSink {
    fn seek(&mut self, _: SeekFrom) -> Result<u64> {
        Ok(0)
    }
}

#[bench]
fn encrypt(b: &mut test::Bencher){
    b.iter(|| test::black_box(dl::encode_with_checksum([0; 8], &mut TEST_DATA, &mut SeekableSink::default())).unwrap());
}

#[bench]
fn encrypt_no_checksum(b: &mut test::Bencher){
    b.iter(|| test::black_box(dl::encode_no_checksum([0; 8], &mut TEST_DATA, &mut SeekableSink::default())).unwrap());
}

#[bench]
fn decrypt(b: &mut test::Bencher){
    b.iter(|| test::black_box(dl::decode([0; 8], &mut TEST_DATA_DELTA, &mut SeekableSink::default())).unwrap());
}

#[bench]
fn decrypt_no_checksum(b: &mut test::Bencher){
    b.iter(|| test::black_box(dl::decode([0; 8], &mut TEST_DATA_DELTA_NOC, &mut SeekableSink::default())).unwrap());
}

{'fraction_non_alphanumeric': 0.2116788321167883, 'fraction_numerical': 0.01013787510137875, 'mean_word_length': 5.325641025641025, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6372487', 'n_tokens_mistral': 961, 'n_tokens_neox': 985, 'n_words': 192}