quick fixes
This commit is contained in:
parent
a20d92c03b
commit
f0a6376a9e
@ -10,7 +10,8 @@ extern crate test;
|
|||||||
extern crate ethcore_util;
|
extern crate ethcore_util;
|
||||||
|
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
use ethcore_util::rlp::{RlpStream};
|
use ethcore_util::rlp;
|
||||||
|
use ethcore_util::rlp::{RlpStream, Rlp, Decodable};
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_stream_value(b: &mut Bencher) {
|
fn bench_stream_value(b: &mut Bencher) {
|
||||||
@ -34,6 +35,19 @@ fn bench_stream_nested_empty_lists(b: &mut Bencher) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[bench]
|
||||||
|
fn bench_decode_nested_empty_lists(b: &mut Bencher) {
|
||||||
|
b.iter( || {
|
||||||
|
// [ [], [[]], [ [], [[]] ] ]
|
||||||
|
let data = vec![0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0];
|
||||||
|
let rlp = Rlp::new(&data);
|
||||||
|
let v0: Vec<u8> = Decodable::decode(&rlp.at(0).unwrap()).unwrap();
|
||||||
|
let v1: Vec<Vec<u8>> = Decodable::decode(&rlp.at(1).unwrap()).unwrap();
|
||||||
|
let v2a: Vec<u8> = Decodable::decode(&rlp.at(2).unwrap().at(0).unwrap()).unwrap();
|
||||||
|
let v2b: Vec<Vec<u8>> = Decodable::decode(&rlp.at(2).unwrap().at(1).unwrap()).unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_stream_1000_empty_lists(b: &mut Bencher) {
|
fn bench_stream_1000_empty_lists(b: &mut Bencher) {
|
||||||
b.iter( || {
|
b.iter( || {
|
||||||
|
@ -262,7 +262,7 @@ impl <T> Decodable for Vec<T> where T: Decodable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Decoder {
|
pub trait Decoder {
|
||||||
fn read_value<T>(bytes: &[u8]) -> Result<T, DecoderError> where T: FromBytes;
|
fn read_value<T>(bytes: &[u8]) -> Result<T, DecoderError> where T: FromBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user