Skip to content

Commit

Permalink
chore: add benches_{tokio,vs_actix-web} & add [profile.release] c…
Browse files Browse the repository at this point in the history
…onfig to `benches_*` (#254)

* add `benches_{tokio,vs_actix-web}` & add `[profile.release]` to benches

* refactor directory structure
  • Loading branch information
kanarus authored Aug 23, 2024
1 parent 48aa379 commit 979c738
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 51 deletions.
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ members = [
]
exclude = [
"benches",
"benches_smol",
"benches_glommio",
"benches_rt/glommio",
"benches_rt/smol",
"benches_rt/tokio",
"benches_rt/vs_actix-web",
]

[workspace.dependencies]
Expand Down
12 changes: 10 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
version: '3'

tasks:
CI:
deps:
- test
- check
- bench_dryrun

test:
deps:
- test_doc
Expand All @@ -25,8 +31,10 @@ tasks:
cmds:
- cd benches && cargo bench --features DEBUG --no-run
- cd benches && cargo check
- cd benches_glommio && cargo check
- cd benches_smol && cargo check
- cd benches_rt/glommio && cargo check
- cd benches_rt/smol && cargo check
- cd benches_rt/tokio && cargo check
- cd benches_rt/vs_actix-web && cargo check

bench:
dir: benches
Expand Down
11 changes: 11 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ hashbrown = { version = "0.14.5", features = ["raw", "inline-more"] }
[dev-dependencies]
rand = "0.8.5"
rand_chacha = "0.3.1"

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false
45 changes: 0 additions & 45 deletions benches/src/bin/hello.rs

This file was deleted.

13 changes: 12 additions & 1 deletion benches_glommio/Cargo.toml → benches_rt/glommio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@ authors = ["kanarus <[email protected]>"]

[dependencies]
# set `default-features = false` to assure "DEBUG" feature be off even when DEBUGing `../ohkami`
ohkami = { path = "../ohkami", default-features = false, features = ["rt_glommio"] }
ohkami = { path = "../../ohkami", default-features = false, features = ["rt_glommio"] }
glommio = { version = "0.9" }

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false
File renamed without changes.
13 changes: 12 additions & 1 deletion benches_smol/Cargo.toml → benches_rt/smol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@ authors = ["kanarus <[email protected]>"]

[dependencies]
# set `default-features = false` to assure "DEBUG" feature be off even when DEBUGing `../ohkami`
ohkami = { path = "../ohkami", default-features = false, features = ["rt_smol"] }
ohkami = { path = "../../ohkami", default-features = false, features = ["rt_smol"] }
smol = { version = "2" }

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false
File renamed without changes.
21 changes: 21 additions & 0 deletions benches_rt/tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "ohkami_benches-with-tokio"
version = "0.0.0"
edition = "2021"
authors = ["kanarus <[email protected]>"]

[dependencies]
# set `default-features = false` to assure "DEBUG" feature be off even when DEBUGing `../ohkami`
ohkami = { path = "../../ohkami", default-features = false, features = ["rt_tokio"] }
tokio = { version = "1", features = ["full"] }

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false
20 changes: 20 additions & 0 deletions benches_rt/tokio/src/bin/hello.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use ohkami::prelude::*;
use ohkami::format::JSON;

#[derive(Serialize)]
struct Message {
message: String
}

async fn hello(name: &str) -> JSON<Message> {
JSON(Message {
message: format!("Hello, {name}!")
})
}

#[tokio::main]
async fn main() {
Ohkami::new((
"/hello/:name".GET(hello),
)).howl("localhost:3000").await
}
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions benches_rt/vs_actix-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "ohkami_benches_vs_actix-web"
version = "0.0.0"
edition = "2021"
authors = ["kanarus <[email protected]>"]

[dependencies]
actix-web = { version = "4" }

[profile.release]
opt-level = 3
debug = false
debug-assertions = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
strip = false
16 changes: 16 additions & 0 deletions benches_rt/vs_actix-web/src/bin/param.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use actix_web::{get, web, App, HttpServer};

#[get("/user/{id}")]
async fn echo(id: web::Path<String>) -> String {
id.into_inner()
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(echo)
})
.bind("0.0.0.0:3000")?
.run().await
}

0 comments on commit 979c738

Please sign in to comment.