Fix errors in benchmarks

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/32/head
trivernis 3 years ago
parent 2527763494
commit 51f53e7fbe
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -3,13 +3,13 @@ use criterion::{criterion_group, criterion_main};
use criterion::{BatchSize, Criterion};
use std::io::Cursor;
use bromine::event::Event;
use bromine::event::{Event, EventType};
use tokio::runtime::Runtime;
pub const EVENT_NAME: &str = "bench_event";
fn create_event_bytes_reader(data_size: usize) -> Cursor<Vec<u8>> {
let bytes = Event::new(EVENT_NAME.to_string(), vec![0u8; data_size], None)
let bytes = Event::initiator(None, EVENT_NAME.to_string(), vec![0u8; data_size])
.into_bytes()
.unwrap();
Cursor::new(bytes)

@ -6,7 +6,7 @@ use criterion::{
pub const EVENT_NAME: &str = "bench_event";
fn create_event(data_size: usize) -> Event {
Event::new(EVENT_NAME.to_string(), vec![0u8; data_size], None)
Event::initiator(None, EVENT_NAME.to_string(), vec![0u8; data_size])
}
fn event_serialization(c: &mut Criterion) {

@ -41,31 +41,21 @@ impl Event {
/// Creates a new event that acts as an initiator for further response events
#[tracing::instrument(level = "trace", skip(data))]
#[inline]
pub(crate) fn initiator(namespace: Option<String>, name: String, data: Vec<u8>) -> Self {
pub fn initiator(namespace: Option<String>, name: String, data: Vec<u8>) -> Self {
Self::new(namespace, name, data, None, EventType::Initiator)
}
/// Creates a new event that is a response to a previous event
#[tracing::instrument(level = "trace", skip(data))]
#[inline]
pub(crate) fn response(
namespace: Option<String>,
name: String,
data: Vec<u8>,
ref_id: u64,
) -> Self {
pub fn response(namespace: Option<String>, name: String, data: Vec<u8>, ref_id: u64) -> Self {
Self::new(namespace, name, data, Some(ref_id), EventType::Response)
}
/// Creates a new error event as a response to a previous event
#[tracing::instrument(level = "trace", skip(data))]
#[inline]
pub(crate) fn error(
namespace: Option<String>,
name: String,
data: Vec<u8>,
ref_id: u64,
) -> Self {
pub fn error(namespace: Option<String>, name: String, data: Vec<u8>, ref_id: u64) -> Self {
Self::new(namespace, name, data, Some(ref_id), EventType::Error)
}
@ -73,7 +63,7 @@ impl Event {
/// and might contain a final response payload
#[tracing::instrument(level = "trace", skip(data))]
#[inline]
pub(crate) fn end(namespace: Option<String>, name: String, data: Vec<u8>, ref_id: u64) -> Self {
pub fn end(namespace: Option<String>, name: String, data: Vec<u8>, ref_id: u64) -> Self {
Self::new(namespace, name, data, Some(ref_id), EventType::Response)
}

Loading…
Cancel
Save