Add benchmarks for block serialization

This commit is contained in:
Elichai Turkel 2020-03-29 15:54:15 +03:00
parent 8c82129442
commit 609b9523b8
No known key found for this signature in database
GPG Key ID: 9383CDE9E8E66A7F
2 changed files with 78 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -99,3 +99,33 @@ pub use util::amount::SignedAmount;
pub use util::key::PrivateKey;
pub use util::key::PublicKey;
pub use util::merkleblock::MerkleBlock;
#[cfg(all(test, feature = "unstable"))] use tests::EmptyWrite;
#[cfg(all(test, feature = "unstable"))]
mod tests {
use hashes::core::fmt::Arguments;
use std::io::{IoSlice, Result, Write};
#[derive(Default, Clone, Debug, PartialEq, Eq)]
pub struct EmptyWrite;
impl Write for EmptyWrite {
fn write(&mut self, buf: &[u8]) -> Result<usize> {
Ok(buf.len())
}
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize> {
Ok(bufs.iter().map(|s| s.len()).sum())
}
fn flush(&mut self) -> Result<()> {
Ok(())
}
fn write_all(&mut self, _: &[u8]) -> Result<()> {
Ok(())
}
fn write_fmt(&mut self, _: Arguments) -> Result<()> {
Ok(())
}
}
}