Skip to content

Commit 6cee69a

Browse files
author
Nick Ashley
authored
Add tide and warp (#4)
1 parent 0ee1374 commit 6cee69a

File tree

6 files changed

+65
-5
lines changed

6 files changed

+65
-5
lines changed

Diff for: benchmark/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ members = [
55
"hello-world/axum",
66
"hello-world/hyper",
77
"hello-world/rocket",
8+
"hello-world/tide",
9+
"hello-world/warp",
810
]

Diff for: benchmark/hello-world/tide/Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "hello-world-tide"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
tide = "0.16"
10+
async-std = { version = "1.8", features = ["attributes"] }
11+
#serde = { version = "1", features = ["derive"] }

Diff for: benchmark/hello-world/tide/src/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[async_std::main]
2+
async fn main() -> Result<(), std::io::Error> {
3+
let mut app = tide::new();
4+
app.at("/").get(|_| async { Ok("Hello, World!") });
5+
app.listen("127.0.0.1:3000").await?;
6+
Ok(())
7+
}

Diff for: benchmark/hello-world/warp/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "hello-world-warp"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
tokio = { version = "1", features = ["full"] }
10+
warp = "0.3"

Diff for: benchmark/hello-world/warp/src/main.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//#![deny(warnings)]
2+
use warp::Filter;
3+
4+
#[tokio::main]
5+
async fn main() {
6+
// Match any request and return hello world!
7+
let routes = warp::any().map(|| "Hello, World!");
8+
9+
warp::serve(routes).run(([127, 0, 0, 1], 3000)).await;
10+
}

Diff for: result/hello-world/hello-world.sh

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
11
# note: "rewrk" needs to be in $PATH
22
# used rewrk: https://github.com/programatik29/rewrk/tree/single-thread
33
trap "kill 0" SIGINT
4+
export bench_cmd="rewrk -t 12 -c 500 -d 30s -h http://127.0.0.1:3000"
45
cd ../../benchmark
56
cargo build --release --bin hello-world-actix-web
67
cargo build --release --bin hello-world-axum
78
cargo build --release --bin hello-world-hyper
89
cargo +nightly build --release --bin hello-world-rocket
10+
cargo build --release --bin hello-world-tide
11+
cargo build --release --bin hello-world-warp
912
(
1013
# actix-web
1114
echo "Actix Web:"
1215
cargo run -q --release --bin hello-world-actix-web &
1316
sleep 1
14-
rewrk -t 12 -c 500 -d 10s -h http://127.0.0.1:3000
17+
eval $bench_cmd
1518
kill $!
19+
1620
# axum
1721
echo "Axum:"
1822
cargo run -q --release --bin hello-world-axum &
1923
sleep 1
20-
rewrk -t 12 -c 500 -d 10s -h http://127.0.0.1:3000
24+
eval $bench_cmd
2125
kill $!
26+
2227
# hyper
2328
echo "Hyper:"
2429
cargo run -q --release --bin hello-world-hyper &
2530
sleep 1
26-
rewrk -t 12 -c 500 -d 10s -h http://127.0.0.1:3000
31+
eval $bench_cmd
2732
kill $!
33+
2834
# rocket
2935
echo "Rocket:"
30-
cargo +nightly run -q --release --bin hello-world-rocket &
36+
ROCKET_ENV=prod ROCKET_PORT=3000 cargo +nightly run -q --release --bin hello-world-rocket &
3137
sleep 1
32-
rewrk -t 12 -c 500 -d 10s -h http://127.0.0.1:8000
38+
eval $bench_cmd
39+
kill $!
40+
41+
# tide
42+
echo "Tide:"
43+
cargo run -q --release --bin hello-world-tide &
44+
sleep 1
45+
eval $bench_cmd
46+
kill $!
47+
48+
# warp
49+
echo "Warp:"
50+
cargo run -q --release --bin hello-world-warp &
51+
sleep 1
52+
eval $bench_cmd
3353
kill $!
3454
) | tee ../result/hello-world/hello-world.stdout

0 commit comments

Comments
 (0)