Skip to content

Add Viz #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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