public snapshot · system/tools/nib/bench/xlang/ · system@main · commit a92f56ab098e · shared 2026-11-22T22:43:57Z· frozen: this page does not change when the repository does
all files
  1//! The HTTP benchmark: GET /plaintext and GET /json on port 18442, with axum
  2//! on tokio's multi-threaded runtime and serde for the JSON.
  3use axum::{routing::get, Json, Router};
  4use serde::Serialize;
  5
  6#[derive(Serialize)]
  7struct Message {
  8    message: &'static str,
  9}
 10
 11#[tokio::main]
 12async fn main() {
 13    let app = Router::new()
 14        .route("/plaintext", get(|| async { "Hello, World!" }))
 15        .route(
 16            "/json",
 17            get(|| async {
 18                Json(Message {
 19                    message: "Hello, World!",
 20                })
 21            }),
 22        );
 23    let listener = tokio::net::TcpListener::bind("0.0.0.0:18442")
 24        .await
 25        .unwrap();
 26    axum::serve(listener, app).await.unwrap();
 27}