Skip to content

Commit

Permalink
Added benchmark generation code
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdi-shojaee committed Oct 19, 2023
1 parent a5f9ef1 commit 1f29c89
Show file tree
Hide file tree
Showing 36 changed files with 6,216 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rust-analyzer.linkedProjects": [
"./benchmark/Cargo.toml"
]
}
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[workspace]
members = ["benchmark"]

[package]
name = "loole"
version = "0.1.3"
version = "0.1.4"
edition = "2021"
authors = ["Mahdi Shojaee <msh6180339@gmail.com>"]
description = "A safe async/sync multi-producer, multi-consumer channel"
Expand Down
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,55 @@ fn main() {
To use Loole, place the following line under the `[dependencies]` section in your `Cargo.toml`:

```toml
loole = "0.1.3"
loole = "0.1.4"
```

## Benchmarks

Benchmarks measure throughput, which is the number of messages sent and received per second, for messages of 264 bytes each.

### MPSC
### Run benchmarks

To run benchmarks on your local machine, run the following command:

```bash
cargo run --release -p benchmark
```

5000 producers send messages to 1 consumer.
The above command will generate and update the benchmark images in the README.md file.

### MPSC

Measures: Messages per seconds. (higher is better)

Messages size: 264 bytes.

![MPSC](misc/loole-mpsc.png)
![MPSC: sync-sync](benchmark/charts/images/mpsc-sync-sync.svg)
![MPSC: async-async](benchmark/charts/images/mpsc-async-async.svg)
![MPSC: async-sync](benchmark/charts/images/mpsc-async-sync.svg)
![MPSC: sync-async](benchmark/charts/images/mpsc-sync-async.svg)

### MPMC

5000 producers send messages to 2 consumers.

Measures: Messages per seconds. (higher is better)

Messages size: 264 bytes.

![MPMC](misc/loole-mpmc.png)
![MPMC: sync-sync](benchmark/charts/images/mpmc-sync-sync.svg)
![MPMC: async-async](benchmark/charts/images/mpmc-async-async.svg)
![MPMC: async-sync](benchmark/charts/images/mpmc-async-sync.svg)
![MPMC: sync-async](benchmark/charts/images/mpmc-sync-async.svg)

### SPSC

1 producer send messages to 1 consumer.

Measures: Messages per seconds. (higher is better)

Messages size: 264 bytes.

![SPSC](misc/loole-spsc.png)
![SPSC: sync-sync](benchmark/charts/images/spsc-sync-sync.svg)
![SPSC: async-async](benchmark/charts/images/spsc-async-async.svg)
![SPSC: async-sync](benchmark/charts/images/spsc-async-sync.svg)
![SPSC: sync-async](benchmark/charts/images/spsc-sync-async.svg)

## License

Expand Down
15 changes: 15 additions & 0 deletions benchmark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "benchmark"
version = "0.1.0"
edition = "2021"

[dependencies]
loole = { path = ".." }
async-channel = "1.9.0"
flume = "0.10.14"
kanal = { version = "0.1.0-pre8", features = ["std-mutex"] }
crossbeam-channel = "0.5.8"
tokio = { version = "1.31.0", features = ["full"] }
num-format = "0.4.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.107"
24 changes: 24 additions & 0 deletions benchmark/charts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Loading

0 comments on commit 1f29c89

Please sign in to comment.