Skip to content

Commit

Permalink
Add Viz (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon authored Jul 18, 2022
1 parent 8fdf85d commit ac5f522
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ members = [
"hello-world/thruster",
"hello-world/tide",
"hello-world/warp",
"hello-world/poem"
"hello-world/poem",
"hello-world/viz"
]
8 changes: 8 additions & 0 deletions benchmark/hello-world/viz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "hello-world-viz"
version = "0.1.0"
edition = "2021"

[dependencies]
viz = { version = "0.2" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
20 changes: 20 additions & 0 deletions benchmark/hello-world/viz/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![deny(warnings)]

use std::net::SocketAddr;
use viz::{get, Request, Result, Router, Server, ServiceMaker, Error};

async fn index(_: Request) -> Result<&'static str> {
Ok("Hello, World!")
}

#[tokio::main]
async fn main() -> Result<()> {
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let app = Router::new().route("/", get(index));

Server::bind(&addr)
.tcp_nodelay(true)
.serve(ServiceMaker::from(app))
.await
.map_err(Error::normal)
}
7 changes: 7 additions & 0 deletions result/hello-world/hello-world.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ sleep 1
eval $bench_cmd
kill $!

# viz
echo "Viz:"
cargo run -q --release --bin hello-world-viz &
sleep 1
eval $bench_cmd
kill $!

# warp
echo "Warp:"
cargo run -q --release --bin hello-world-warp &
Expand Down

0 comments on commit ac5f522

Please sign in to comment.