-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/aggregation
- Loading branch information
Showing
17 changed files
with
777 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use criterion::black_box; | ||
use fa_compression::algorithm1::{ | ||
decode, | ||
encode | ||
}; | ||
|
||
use super::util::generate_annotation; | ||
|
||
/// Generate a random number of encoded annotations. | ||
fn generate_encoded_annotations(count: usize) -> Vec<u8> { | ||
let mut random = rand::thread_rng(); | ||
|
||
let mut annotations = String::new(); | ||
for _ in 0 .. count { | ||
annotations.push_str(&generate_annotation(&mut random)); | ||
annotations.push(';'); | ||
} | ||
annotations.pop(); | ||
|
||
encode(annotations.as_str()) | ||
} | ||
|
||
pub fn decode_benchmark(c: &mut criterion::Criterion) { | ||
c.bench_function("decode_algorithm1", |b| { | ||
b.iter_batched( | ||
|| generate_encoded_annotations(100), | ||
|annotations| black_box(decode(annotations.as_slice())), | ||
criterion::BatchSize::SmallInput | ||
) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use criterion::black_box; | ||
use fa_compression::algorithm1::encode; | ||
|
||
use super::util::generate_annotation; | ||
|
||
/// Generate a random number of decoded annotations. | ||
fn generate_decoded_annotations(count: usize) -> String { | ||
let mut random = rand::thread_rng(); | ||
|
||
let mut annotations = String::new(); | ||
for _ in 0 .. count { | ||
annotations.push_str(&generate_annotation(&mut random)); | ||
annotations.push(';'); | ||
} | ||
|
||
annotations.pop(); | ||
annotations | ||
} | ||
|
||
pub fn encode_benchmark(c: &mut criterion::Criterion) { | ||
c.bench_function("encode_algorithm1", |b| { | ||
b.iter_batched( | ||
|| generate_decoded_annotations(100), | ||
|annotations| black_box(encode(annotations.as_str())), | ||
criterion::BatchSize::SmallInput | ||
) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use criterion::criterion_group; | ||
|
||
use super::util; | ||
|
||
mod decode; | ||
mod encode; | ||
|
||
criterion_group!(benches, encode::encode_benchmark, decode::decode_benchmark); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use criterion::black_box; | ||
use fa_compression::algorithm2::{ | ||
decode, | ||
encode, | ||
CompressionTable | ||
}; | ||
|
||
use super::util::generate_annotation; | ||
|
||
fn generate_encoded_annotations_and_table(count: usize) -> (Vec<u8>, CompressionTable) { | ||
let mut random = rand::thread_rng(); | ||
|
||
let mut compression_table1 = CompressionTable::new(); | ||
let mut compression_table2 = CompressionTable::new(); | ||
|
||
let mut annotations = String::new(); | ||
for _ in 0 .. count { | ||
let annotation = generate_annotation(&mut random); | ||
annotations.push_str(&annotation); | ||
annotations.push(';'); | ||
compression_table1.add_entry(annotation.clone()); | ||
compression_table2.add_entry(annotation); | ||
} | ||
|
||
annotations.pop(); | ||
|
||
(encode(annotations.as_str(), compression_table1), compression_table2) | ||
} | ||
|
||
pub fn decode_benchmark(c: &mut criterion::Criterion) { | ||
c.bench_function("decode_algorithm2", |b| { | ||
b.iter_batched( | ||
|| generate_encoded_annotations_and_table(100), | ||
|(annotations, ct)| black_box(decode(annotations.as_slice(), ct)), | ||
criterion::BatchSize::SmallInput | ||
) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use criterion::black_box; | ||
use fa_compression::algorithm2::{ | ||
encode, | ||
CompressionTable | ||
}; | ||
|
||
use super::util::generate_annotation; | ||
|
||
fn generate_decoded_annotations_and_table(count: usize) -> (String, CompressionTable) { | ||
let mut random = rand::thread_rng(); | ||
|
||
let mut compression_table = CompressionTable::new(); | ||
|
||
let mut annotations = String::new(); | ||
for _ in 0 .. count { | ||
let annotation = generate_annotation(&mut random); | ||
annotations.push_str(&annotation); | ||
annotations.push(';'); | ||
compression_table.add_entry(annotation); | ||
} | ||
|
||
annotations.pop(); | ||
|
||
(annotations, compression_table) | ||
} | ||
|
||
pub fn encode_benchmark(c: &mut criterion::Criterion) { | ||
c.bench_function("encode_algorithm2", |b| { | ||
b.iter_batched( | ||
|| generate_decoded_annotations_and_table(100), | ||
|(annotations, ct)| black_box(encode(annotations.as_str(), ct)), | ||
criterion::BatchSize::SmallInput | ||
) | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use criterion::criterion_group; | ||
|
||
use super::util; | ||
|
||
mod decode; | ||
mod encode; | ||
|
||
criterion_group!(benches, encode::encode_benchmark, decode::decode_benchmark); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,7 @@ | ||
use criterion::{ | ||
black_box, | ||
criterion_group, | ||
criterion_main | ||
}; | ||
use fa_compression::{ | ||
decode, | ||
encode | ||
}; | ||
use criterion::criterion_main; | ||
|
||
mod algorithm1; | ||
mod algorithm2; | ||
mod util; | ||
|
||
fn encode_benchmark(c: &mut criterion::Criterion) { | ||
c.bench_function("encode", |b| { | ||
b.iter_batched( | ||
|| util::generate_decoded_annotations(100), | ||
|annotations| black_box(encode(annotations.as_str())), | ||
criterion::BatchSize::SmallInput | ||
) | ||
}); | ||
} | ||
|
||
fn decode_benchmark(c: &mut criterion::Criterion) { | ||
c.bench_function("decode", |b| { | ||
b.iter_batched( | ||
|| util::generate_encoded_annotations(100), | ||
|annotations| black_box(decode(annotations.as_slice())), | ||
criterion::BatchSize::SmallInput | ||
) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, encode_benchmark, decode_benchmark); | ||
criterion_main!(benches); | ||
criterion_main!(algorithm1::benches, algorithm2::benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.