mirror of
https://github.com/edg-l/rustyman.git
synced 2024-11-21 15:38:21 +00:00
format
This commit is contained in:
parent
f8e093a19b
commit
6c61ceb024
|
@ -1,7 +1,6 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use rustyman::Huffman;
|
use rustyman::Huffman;
|
||||||
|
|
||||||
|
|
||||||
fn criterion_benchmark(c: &mut Criterion) {
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
c.bench_function("compress", |b| {
|
c.bench_function("compress", |b| {
|
||||||
let huffman = Huffman::new_from_data(include_bytes!("../assets/bench_input.txt"));
|
let huffman = Huffman::new_from_data(include_bytes!("../assets/bench_input.txt"));
|
||||||
|
|
|
@ -223,10 +223,9 @@ impl Huffman {
|
||||||
for b in data.iter() {
|
for b in data.iter() {
|
||||||
self.traverse(
|
self.traverse(
|
||||||
&mut bits,
|
&mut bits,
|
||||||
*self
|
*self.indexes.get(b).unwrap_or_else(|| {
|
||||||
.indexes
|
panic!("frequency table did not contain this byte: {:?}", b)
|
||||||
.get(b)
|
}),
|
||||||
.unwrap_or_else(|| panic!("frequency table did not contain this byte: {:?}", b)),
|
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -309,7 +308,6 @@ mod tests {
|
||||||
assert_eq!(*table.get(&1).unwrap(), 1);
|
assert_eq!(*table.get(&1).unwrap(), 1);
|
||||||
assert_eq!(*table.get(&2).unwrap(), 2);
|
assert_eq!(*table.get(&2).unwrap(), 2);
|
||||||
assert_eq!(*table.get(&3).unwrap(), 3);
|
assert_eq!(*table.get(&3).unwrap(), 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue