Skip to content

Commit ac5f522

Browse files
authored
Add Viz (#15)
1 parent 8fdf85d commit ac5f522

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

benchmark/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ members = [
1111
"hello-world/thruster",
1212
"hello-world/tide",
1313
"hello-world/warp",
14-
"hello-world/poem"
14+
"hello-world/poem",
15+
"hello-world/viz"
1516
]

benchmark/hello-world/viz/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "hello-world-viz"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
viz = { version = "0.2" }
8+
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

benchmark/hello-world/viz/src/main.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![deny(warnings)]
2+
3+
use std::net::SocketAddr;
4+
use viz::{get, Request, Result, Router, Server, ServiceMaker, Error};
5+
6+
async fn index(_: Request) -> Result<&'static str> {
7+
Ok("Hello, World!")
8+
}
9+
10+
#[tokio::main]
11+
async fn main() -> Result<()> {
12+
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
13+
let app = Router::new().route("/", get(index));
14+
15+
Server::bind(&addr)
16+
.tcp_nodelay(true)
17+
.serve(ServiceMaker::from(app))
18+
.await
19+
.map_err(Error::normal)
20+
}

result/hello-world/hello-world.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ sleep 1
8585
eval $bench_cmd
8686
kill $!
8787

88+
# viz
89+
echo "Viz:"
90+
cargo run -q --release --bin hello-world-viz &
91+
sleep 1
92+
eval $bench_cmd
93+
kill $!
94+
8895
# warp
8996
echo "Warp:"
9097
cargo run -q --release --bin hello-world-warp &

0 commit comments

Comments
 (0)