Introduce Cargo workspace in prep for schema

This commit is contained in:
Tony Garnock-Jones 2021-04-19 22:28:59 +02:00
parent b4d7af4322
commit 825d208198
34 changed files with 43 additions and 37 deletions

View File

@ -1,25 +1,4 @@
[package] [workspace]
name = "preserves" members = [
version = "0.12.0" "preserves",
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"] ]
edition = "2018"
description = "Implementation of the Preserves serialization format via serde."
homepage = "https://preserves.gitlab.io/"
repository = "https://gitlab.com/preserves/preserves"
license = "Apache-2.0"
[badges]
gitlab = { repository = "preserves/preserves" }
[dependencies]
num = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
lazy_static = "1.4.0"
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "codec"
harness = false

View File

@ -1 +0,0 @@
uApplevColourSreduApplevColourUgreen„vBananaykilograms¸Që…¸vColourXbrownish5tPear<61>zConference

View File

@ -1 +0,0 @@
浮uAppleColourSred「PeachAppleColourUgreen<EFBFBD>Bananakilograms?セクQ<EFBDB8>ColourXbrownish5イxripeness『SquishyPear】Conference

View File

@ -0,0 +1,25 @@
[package]
name = "preserves"
version = "0.12.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Implementation of the Preserves serialization format via serde."
homepage = "https://preserves.gitlab.io/"
repository = "https://gitlab.com/preserves/preserves"
license = "Apache-2.0"
[badges]
gitlab = { repository = "preserves/preserves" }
[dependencies]
num = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
lazy_static = "1.4.0"
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "codec"
harness = false

View File

@ -10,7 +10,7 @@ mod samples;
use samples::TestCases; use samples::TestCases;
pub fn bench_decoder_bytes(c: &mut Criterion) { pub fn bench_decoder_bytes(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let mut bs = vec![]; let mut bs = vec![];
fh.read_to_end(&mut bs).ok(); fh.read_to_end(&mut bs).ok();
c.bench_function("decode samples.bin via bytes", |b| b.iter_with_large_drop( c.bench_function("decode samples.bin via bytes", |b| b.iter_with_large_drop(
@ -18,7 +18,7 @@ pub fn bench_decoder_bytes(c: &mut Criterion) {
} }
pub fn bench_decoder_file(c: &mut Criterion) { pub fn bench_decoder_file(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
c.bench_function("decode samples.bin via file", |b| b.iter_with_large_drop(|| { c.bench_function("decode samples.bin via file", |b| b.iter_with_large_drop(|| {
fh.seek(SeekFrom::Start(0)).ok(); fh.seek(SeekFrom::Start(0)).ok();
PackedReader::decode_read(&mut fh).demand_next(true).unwrap() PackedReader::decode_read(&mut fh).demand_next(true).unwrap()
@ -26,7 +26,7 @@ pub fn bench_decoder_file(c: &mut Criterion) {
} }
pub fn bench_decoder_buffered_file(c: &mut Criterion) { pub fn bench_decoder_buffered_file(c: &mut Criterion) {
let mut fh = BufReader::new(std::fs::File::open("../../tests/samples.bin").unwrap()); let mut fh = BufReader::new(std::fs::File::open("../../../tests/samples.bin").unwrap());
c.bench_function("decode samples.bin via buffered file", |b| b.iter_with_large_drop(|| { c.bench_function("decode samples.bin via buffered file", |b| b.iter_with_large_drop(|| {
fh.seek(SeekFrom::Start(0)).ok(); fh.seek(SeekFrom::Start(0)).ok();
PackedReader::decode_read(&mut fh).demand_next(true).unwrap() PackedReader::decode_read(&mut fh).demand_next(true).unwrap()
@ -34,7 +34,7 @@ pub fn bench_decoder_buffered_file(c: &mut Criterion) {
} }
pub fn bench_encoder(c: &mut Criterion) { pub fn bench_encoder(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let v = PackedReader::decode_read(&mut fh).demand_next(true).unwrap(); let v = PackedReader::decode_read(&mut fh).demand_next(true).unwrap();
c.bench_function("encode samples.bin", |b| b.iter_with_large_drop(|| { c.bench_function("encode samples.bin", |b| b.iter_with_large_drop(|| {
let mut bs = vec![]; let mut bs = vec![];
@ -44,7 +44,7 @@ pub fn bench_encoder(c: &mut Criterion) {
} }
pub fn bench_de(c: &mut Criterion) { pub fn bench_de(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let mut bs = vec![]; let mut bs = vec![];
fh.read_to_end(&mut bs).ok(); fh.read_to_end(&mut bs).ok();
c.bench_function("deserialize samples.bin", |b| b.iter_with_large_drop( c.bench_function("deserialize samples.bin", |b| b.iter_with_large_drop(
@ -52,7 +52,7 @@ pub fn bench_de(c: &mut Criterion) {
} }
pub fn bench_ser(c: &mut Criterion) { pub fn bench_ser(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let v: TestCases = de::from_read(&mut fh).unwrap(); let v: TestCases = de::from_read(&mut fh).unwrap();
c.bench_function("serialize samples.bin", |b| b.iter_with_large_drop(|| { c.bench_function("serialize samples.bin", |b| b.iter_with_large_drop(|| {
let mut bs = vec![]; let mut bs = vec![];
@ -62,7 +62,7 @@ pub fn bench_ser(c: &mut Criterion) {
} }
pub fn bench_decoder_de(c: &mut Criterion) { pub fn bench_decoder_de(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let mut bs = vec![]; let mut bs = vec![];
fh.read_to_end(&mut bs).ok(); fh.read_to_end(&mut bs).ok();
c.bench_function("decode-then-deserialize samples.bin", |b| b.iter_with_large_drop( c.bench_function("decode-then-deserialize samples.bin", |b| b.iter_with_large_drop(
@ -70,7 +70,7 @@ pub fn bench_decoder_de(c: &mut Criterion) {
} }
pub fn bench_ser_encoder(c: &mut Criterion) { pub fn bench_ser_encoder(c: &mut Criterion) {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let v: TestCases = de::from_read(&mut fh).unwrap(); let v: TestCases = de::from_read(&mut fh).unwrap();
c.bench_function("serialize-then-encode samples.bin", |b| b.iter_with_large_drop(|| { c.bench_function("serialize-then-encode samples.bin", |b| b.iter_with_large_drop(|| {
let mut bs = vec![]; let mut bs = vec![];

View File

@ -3,7 +3,7 @@ BINARY_FILES=known-data.bin unknown-data.bin
all: $(BINARY_FILES) all: $(BINARY_FILES)
%.bin: %.txt Makefile %.bin: %.txt Makefile
racket ../../racket/preserves/preserves/tool.rkt --atob --no-annotations < $< > $@.tmp || (rm -f $@.tmp; false) racket ../../../racket/preserves/preserves/tool.rkt --atob --no-annotations < $< > $@.tmp || (rm -f $@.tmp; false)
mv $@.tmp $@ mv $@.tmp $@
clean: clean:

View File

@ -0,0 +1,2 @@
µ´³Apple´³Colour±red„„´³Apple´³Colour±green„„´³Banana´³ kilogramsƒ?¾¸Që…¸„´³Colour±brownish„•„´³Pear´³
Conference„„„

View File

@ -0,0 +1,2 @@
µ´³Apple´³Colour±red„„´³Peach„´³Apple´³Colour±green„„´³Banana´³ kilogramsƒ?¾¸Që…¸„´³Colour±brownish„•·³ripeness´³Squishy„„„´³Pear´³
Conference„„„

View File

@ -15,7 +15,7 @@ fn decode_all(bytes: &'_ [u8]) -> Result<Vec<IOValue>, std::io::Error> {
} }
#[test] fn run() -> std::io::Result<()> { #[test] fn run() -> std::io::Result<()> {
let mut fh = std::fs::File::open("../../tests/samples.bin").unwrap(); let mut fh = std::fs::File::open("../../../tests/samples.bin").unwrap();
let mut d = PackedReader::decode_read(&mut fh).configured(true); let mut d = PackedReader::decode_read(&mut fh).configured(true);
let tests: TestCases = deserialize_from_value(&d.next().unwrap().unwrap()).unwrap(); let tests: TestCases = deserialize_from_value(&d.next().unwrap().unwrap()).unwrap();
// println!("{:#?}", tests); // println!("{:#?}", tests);