Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "message_worker"
version = "0.6.0"
version = "0.7.0"
authors = ["Nick Webster <nick@nick.geek.nz>"]
repository = "https://github.com/NickGeek/message_worker/"
description = "Message Worker is a low-ish level library for Rust for the creation of event-listeners using futures and streams. Notably MW supports non-sync and non-send (i.e. non-thread-safe) contexts within listeners."
Expand All @@ -16,13 +16,13 @@ name = "benchmarks"
harness = false

[dependencies]
tokio = { version = "^1.6.0", features = ["rt-multi-thread", "sync", "parking_lot"] }
tokio-stream = { version = "~0.1.6", features = ["sync"] }
ees = "1.0.0"
tokio = { version = "^1.53.3", features = ["rt-multi-thread", "sync", "parking_lot"] }
tokio-stream = { version = "~0.1.19", features = ["sync"] }
thiserror = "2.0.21"

[dev-dependencies]
tokio = { version = "^1.6.0", features = ["rt-multi-thread", "sync", "parking_lot", "macros", "test-util"] }
deno_core = { version = "0.199.0", features = ["default", "include_js_files_for_snapshotting"] }
criterion = { version = "0.5.1", features = ["async_tokio", "html_reports"] }
futures = "~0.3.15"
anyhow = "^1.0.40"
tokio = { version = "^1.53.3", features = ["rt-multi-thread", "sync", "parking_lot", "macros", "test-util"] }
deno_core = "0.412.0"
criterion = { version = "0.8.2", features = ["async_tokio", "html_reports"] }
futures = "~0.3.34"
anyhow = "^1.0.104"
14 changes: 6 additions & 8 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ use tokio_stream::StreamExt;
use anyhow::Result;

use message_worker::{blocking, non_blocking, empty_ctx};
use std::rc::Rc;
use std::sync::Arc;

pub fn listener_creation(c: &mut Criterion) {
c.bench_function("create listener", |b| {
let executor = tokio::runtime::Runtime::new().unwrap();

async fn handle_message(_ctx: Arc<()>, _event: ()) -> Result<Option<()>> { Ok(None) }
async fn handle_message(_ctx: (), _event: ()) -> Result<Option<()>> { Ok(None) }

b.to_async(executor).iter(move || async {
let source = tokio_stream::iter(vec![()]);
Expand All @@ -23,7 +21,7 @@ pub fn listener_process_one(c: &mut Criterion) {
c.bench_function("listener process 1 message", |b| {
let executor = tokio::runtime::Runtime::new().unwrap();

async fn handle_message(_ctx: Arc<()>, _event: ()) -> Result<Option<()>> { Ok(None) }
async fn handle_message(_ctx: (), _event: ()) -> Result<Option<()>> { Ok(None) }

b.to_async(executor).iter(move || async {
let source = tokio_stream::iter(vec![()]);
Expand All @@ -35,7 +33,7 @@ pub fn listener_process_one(c: &mut Criterion) {
pub fn listener_process_many(c: &mut Criterion) {
c.bench_function("listener process 1000 messages", |b| {
let executor = tokio::runtime::Runtime::new().unwrap();
async fn handle_message(_ctx: Arc<()>, _event: ()) -> Result<Option<()>> { Ok(None) }
async fn handle_message(_ctx: (), _event: ()) -> Result<Option<()>> { Ok(None) }

b.to_async(executor).iter(move || async {
let source = futures::stream::repeat(()).take(1000);
Expand All @@ -48,7 +46,7 @@ pub fn blocking_listener_creation(c: &mut Criterion) {
c.bench_function("(blocking) create listener", |b| {
let executor = tokio::runtime::Runtime::new().unwrap();

async fn handle_message(_ctx: Rc<()>, _event: ()) -> Result<Option<()>> { Ok(None) }
async fn handle_message(_ctx: (), _event: ()) -> Result<Option<()>> { Ok(None) }

b.to_async(executor).iter(move || async {
let source = tokio_stream::iter(vec![()]);
Expand All @@ -61,7 +59,7 @@ pub fn blocking_listener_process_one(c: &mut Criterion) {
c.bench_function("(blocking) listener process 1 message", |b| {
let executor = tokio::runtime::Runtime::new().unwrap();

async fn handle_message(_ctx: Rc<()>, _event: ()) -> Result<Option<()>> { Ok(None) }
async fn handle_message(_ctx: (), _event: ()) -> Result<Option<()>> { Ok(None) }

b.to_async(executor).iter(move || async {
let source = tokio_stream::iter(vec![()]);
Expand All @@ -73,7 +71,7 @@ pub fn blocking_listener_process_one(c: &mut Criterion) {
pub fn blocking_listener_process_many(c: &mut Criterion) {
c.bench_function("(blocking) listener process 1000 messages", |b| {
let executor = tokio::runtime::Runtime::new().unwrap();
async fn handle_message(_ctx: Rc<()>, _event: ()) -> Result<Option<()>> { Ok(None) }
async fn handle_message(_ctx: (), _event: ()) -> Result<Option<()>> { Ok(None) }

b.to_async(executor).iter(move || async {
let source = futures::stream::repeat(()).take(1000);
Expand Down
Loading
Loading