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

Commit

Permalink
Merge pull request #42 from AndrewSisley/benchmarkLibrary
Browse files Browse the repository at this point in the history
Benchmark library
  • Loading branch information
AndrewSisley authored Jul 25, 2020
2 parents e823d4e + 6bc3177 commit 3553033
Show file tree
Hide file tree
Showing 31 changed files with 1,121 additions and 1,965 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ other types can be found in the the type's corresponding documentation.

Operation | Database dimensions | Mean time _unchecked (ns) | Mean time (ns)
--- | --- | --- | ---
Single point read | 1 | 2 450 (+/- 300) | 7 500 (+/- 600)
Single point read | 4 | 14 850 (+/- 1 000) | 37 550 (+/- 2 300)
Single point write | 1 | 2 800 (+/- 400) | 7 700 (+/- 400)
Single point write | 4 | 15 400 (+/- 2 500) | 37 700 (+/- 3 000)
Stream read 1 point | 1 | 2 500 (+/- 300) | 10 000 (+/- 850)
Stream read 1 point | 4 | 14 900 (+/- 600) | 42 500 (+/- 6 500)
Stream read 50 000 points | 1 | 27 650 000 (+/- 31 000) | 27 630 000 (+/- 180 000)
Stream read 50 000 points | 4 | 27 660 000 (+/- 1 200 000) | 27 620 000 (+/- 480 000)
Single point read | 1 | 2 600 (+/- 300) | 7 500 (+/- 600)
Single point read | 4 | 15 400 (+/- 1 000) | 37 550 (+/- 2 300)
Single point write | 1 | 2 900 (+/- 200) | 7 700 (+/- 400)
Single point write | 4 | 16 000 (+/- 2 000) | 37 700 (+/- 3 000)
Stream read 1 point | 1 | 2 600 (+/- 200) | 10 000 (+/- 850)
Stream read 1 point | 4 | 16 000 (+/- 1 800) | 42 500 (+/- 6 500)
Stream read 50 000 points | 1 | 28 000 000 (+/- 870 000) | 27 630 000 (+/- 180 000)
Stream read 50 000 points | 4 | 28 200 000 (+/- 800 000) | 27 620 000 (+/- 480 000)

## License

Expand Down
2 changes: 1 addition & 1 deletion cql_storage_types/cql_i16/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/i16.rs"
[dev-dependencies]
cql_db = "^0.2.4"
serial_test = "0.3.2"
cql_storage_type_testing_lib = "^0.2.0"
cql_storage_type_testing_lib = "^0.3.0"

[dependencies]
cql_model = "^0.2"
Expand Down
16 changes: 8 additions & 8 deletions cql_storage_types/cql_i16/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Full benchmark code can be found in [github](https://github.com/AndrewSisley/CQL

Operation | Database dimensions | Mean time _unchecked (ns)
--- | --- | ---
Single point read | 1 | 2 520 (+/- 200)
Single point read | 4 | 15 300 (+/- 1 100)
Single point write | 1 | 2 800 (+/- 300)
Single point write | 4 | 15 350 (+/- 1 500)
Stream read 1 point | 1 | 2 500 (+/- 200)
Stream read 1 point | 4 | 15 400 (+/- 850)
Stream read 50 000 points | 1 | 27 600 000 (+/- 900 000)
Stream read 50 000 points | 4 | 27 400 000 (+/- 90 000)
Single point read | 1 | 2 600 (+/- 100)
Single point read | 4 | 15 500 (+/- 1 000)
Single point write | 1 | 2 900 (+/- 300)
Single point write | 4 | 16 000 (+/- 2 000)
Stream read 1 point | 1 | 2 600 (+/- 150)
Stream read 1 point | 4 | 15 600 (+/- 600)
Stream read 50 000 points | 1 | 27 900 000 (+/- 700 000)
Stream read 50 000 points | 4 | 27 900 000 (+/- 1 000 000)

## Getting started
To get started, add the below dependencies to your Cargo.toml:
Expand Down
140 changes: 11 additions & 129 deletions cql_storage_types/cql_i16/benches/read_single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,167 +5,49 @@ extern crate test;
use constants::DATABASE_LOCATION;
use test::Bencher;
use cql_i16::I16;
use cql_storage_type_testing_lib::benches::read_single;

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

let point1 = [1];
let value1 = 42;

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

cql_db::write_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1,
value1
).unwrap();
let test_fn = read_single::_1d_read_location_1::<I16>(DATABASE_LOCATION, 42);

b.iter(|| {
cql_db::read_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1
).unwrap();
test_fn();
});
}

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

let point1 = [100000];
let value1 = 42;

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

cql_db::write_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1,
value1
).unwrap();
let test_fn = read_single::_1d_read_location_100000::<I16>(DATABASE_LOCATION, 42);

b.iter(|| {
cql_db::read_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1
).unwrap();
test_fn();
});
}

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

let point1 = [1, 1, 1, 1];
let value1 = 5;

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

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

cql_db::write_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1,
value1
).unwrap();
let test_fn = read_single::_4d_read_location_1_1_1_1::<I16>(DATABASE_LOCATION, 42);

b.iter(|| {
cql_db::read_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1
).unwrap();
test_fn();
});
}

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

let point1 = [1, 1, 1, 100000];
let value1 = 5;

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

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

cql_db::write_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1,
value1
).unwrap();
let test_fn = read_single::_4d_read_location_1_1_1_100000::<I16>(DATABASE_LOCATION, 5);

b.iter(|| {
cql_db::read_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1
).unwrap();
test_fn();
});
}

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

let point1 = [1, 100000, 1, 1];
let value1 = 5;

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

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

cql_db::write_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1,
value1
).unwrap();
let test_fn = read_single::_4d_read_location_1_100000_1_1::<I16>(DATABASE_LOCATION, 5);

b.iter(|| {
cql_db::read_value_unchecked::<I16>(
DATABASE_LOCATION,
&point1
).unwrap();
test_fn();
});
}
115 changes: 16 additions & 99 deletions cql_storage_types/cql_i16/benches/read_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,133 +2,50 @@
mod constants;
extern crate test;

use std::io::{ Cursor, SeekFrom, Seek };
use std::io::{ Cursor };
use constants::DATABASE_LOCATION;
use test::{ Bencher };
use cql_i16::{ unpack_stream, I16 };
use cql_storage_type_testing_lib::benches::read_stream;

#[bench]
fn _1d_i16_stream_read_location_1_to_1(b: &mut Bencher) {
let n_values_to_read = 1usize;
let point1 = [1];

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

let mut result = [0];
let mut stream = Cursor::new(Vec::new());
let test_fn = read_stream::_1d_read_empty_location_1_to_1::<I16>(DATABASE_LOCATION, &unpack_i16_stream);

b.iter(|| {
cql_db::read_to_stream_unchecked::<I16>(
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, |idx, value| {
result[idx] = value
}).unwrap();
test_fn();
});
}

#[bench]
fn _1d_i16_stream_read_location_50000_to_100000(b: &mut Bencher) {
let n_values_to_read = 50000usize;
let base_point = [50000u64];

cql_db::create_db_unchecked::<I16>(
DATABASE_LOCATION,
&[100000]
).unwrap();

let mut result = [0; 50000];
let mut stream = Cursor::new(Vec::new());
let test_fn = read_stream::_1d_read_empty_location_50000_to_100000::<I16>(DATABASE_LOCATION, &unpack_i16_stream);

b.iter(|| {
cql_db::read_to_stream_unchecked::<I16>(
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();
});
}

#[bench]
fn _4d_i16_stream_read_location_1_1_1_1_to_1_1_1_1(b: &mut Bencher) {
let n_values_to_read = 1usize;
let base_point = [1, 1, 1, 1];

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

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

let mut result = [0];
let mut stream = Cursor::new(Vec::new());
let test_fn = read_stream::_4d_read_empty_location_1_1_1_1_to_1_1_1_1::<I16>(DATABASE_LOCATION, &unpack_i16_stream);

b.iter(|| {
cql_db::read_to_stream_unchecked::<I16>(
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();
});
}

#[bench]
fn _4d_i16_stream_read_location_1_1_1_50000_to_1_1_1_100000(b: &mut Bencher) {
let n_values_to_read = 50000usize;
let base_point = [1, 1, 1, 50000];

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

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

let mut result = [0; 50000];
let mut stream = Cursor::new(Vec::new());
let test_fn = read_stream::_4d_read_empty_location_1_1_1_50000_to_1_1_1_100000::<I16>(DATABASE_LOCATION, &unpack_i16_stream);

b.iter(|| {
cql_db::read_to_stream_unchecked::<I16>(
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();
});
}

fn unpack_i16_stream (stream: &mut Cursor<Vec<u8>>, n_values: usize, result: &mut [i16]) {
unpack_stream(stream, n_values, |idx, value| {
result[idx] = value
}).unwrap()
}
Loading

0 comments on commit 3553033

Please sign in to comment.