diff --git a/benchmark/Cargo.toml b/benchmark/Cargo.toml index 8807190..ddef59b 100644 --- a/benchmark/Cargo.toml +++ b/benchmark/Cargo.toml @@ -11,5 +11,6 @@ members = [ "hello-world/thruster", "hello-world/tide", "hello-world/warp", - "hello-world/poem" + "hello-world/poem", + "hello-world/viz" ] diff --git a/benchmark/hello-world/viz/Cargo.toml b/benchmark/hello-world/viz/Cargo.toml new file mode 100644 index 0000000..5f2c52a --- /dev/null +++ b/benchmark/hello-world/viz/Cargo.toml @@ -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"] } diff --git a/benchmark/hello-world/viz/src/main.rs b/benchmark/hello-world/viz/src/main.rs new file mode 100644 index 0000000..c3aac61 --- /dev/null +++ b/benchmark/hello-world/viz/src/main.rs @@ -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) +} diff --git a/result/hello-world/hello-world.sh b/result/hello-world/hello-world.sh index 8ad21fc..0e04739 100755 --- a/result/hello-world/hello-world.sh +++ b/result/hello-world/hello-world.sh @@ -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 &