Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Refactor type specific tests to use _4d_read_populated_location_1_1_1…
Browse files Browse the repository at this point in the history
…_1_to_1_1_1_1
  • Loading branch information
AndrewSisley committed Jul 25, 2020
1 parent 1bcbe2a commit b1cbe42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 74 deletions.
43 changes: 2 additions & 41 deletions cql_storage_types/cql_nullable_f64/benches/read_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,10 @@ fn _4d_f64_nullable_stream_read_empty_location_1_1_1_1_to_1_1_1_1(b: &mut Benche

#[bench]
fn _4d_f64_nullable_stream_read_populated_location_1_1_1_1_to_1_1_1_1(b: &mut Bencher) {
let axis = [
2,
2,
2,
2,
];

let n_values_to_read = 1usize;
let base_point = [1, 1, 1, 1];
let base_value = Some(78352.3);

cql_db::create_db_unchecked::<NullableF64>(
DATABASE_LOCATION,
&axis
).unwrap();

cql_db::link_dimensions_unchecked::<NullableF64>(
DATABASE_LOCATION,
&base_point[0..3],
).unwrap();

cql_db::write_value_unchecked::<NullableF64>(
DATABASE_LOCATION,
&base_point,
base_value
).unwrap();

let mut result: [Option<f64>; 1] = [None; 1];
let mut stream = Cursor::new(Vec::new());
let test_fn = read_stream::_4d_read_populated_location_1_1_1_1_to_1_1_1_1::<NullableF64>(DATABASE_LOCATION, Some(78352.3), &unpack_nullable_f64_stream);

b.iter(|| {
cql_db::read_to_stream_unchecked::<NullableF64>(
DATABASE_LOCATION,
&mut stream,
&base_point,
n_values_to_read as u64
).unwrap();

stream.seek(SeekFrom::Start(0)).unwrap();

unpack_stream(&mut stream, n_values_to_read, |idx, value| {
result[idx] = value
}).unwrap();
test_fn();
});
}

Expand Down
39 changes: 6 additions & 33 deletions cql_storage_types/cql_tiny_text/benches/read_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,15 @@ fn _1d_tiny_text_stream_read_255_char_location_50000_to_100000(b: &mut Bencher)

#[bench]
fn _4d_tiny_text_stream_read_1_char_location_1_1_1_1_to_1_1_1_1(b: &mut Bencher) {
const N_VALUES_TO_READ: usize = 1;
let point1 = [1, 1, 1, 1];
let value1 = "1".to_string();

cql_db::create_db_unchecked::<TinyText>(
DATABASE_LOCATION,
&[1, 1, 1, 1]
).unwrap();

cql_db::link_dimensions_unchecked::<TinyText>(
DATABASE_LOCATION,
&point1[0..3],
).unwrap();

cql_db::write_value_unchecked::<TinyText>(
let value1 = "1";
let test_fn = read_stream::_4d_read_populated_location_1_1_1_1_to_1_1_1_1::<TinyText>(
DATABASE_LOCATION,
&point1,
TinyText::try_from(value1).unwrap()
).unwrap();

let mut result = Vec::with_capacity(N_VALUES_TO_READ);
let mut stream = Cursor::new(Vec::new());
TinyText::try_from(value1).unwrap(),
&unpack_tiny_text_stream
);

b.iter(|| {
cql_db::read_to_stream_unchecked::<TinyText>(
DATABASE_LOCATION,
&mut stream,
&point1,
N_VALUES_TO_READ as u64
).unwrap();

stream.seek(SeekFrom::Start(0)).unwrap();

unpack_stream(&mut stream, N_VALUES_TO_READ, |_, value| {
result.push(value)
}).unwrap();
test_fn();
});
}

Expand Down

0 comments on commit b1cbe42

Please sign in to comment.