rust的actix性能很好一致处理前列
image.png
图片来源https://www.techempower.com/benchmarks/#section=data-r17&hw=cl&test=query
在rust 2018中
use actix_web::{App, HttpRequest, middleware, server};
fn index(_req: &HttpRequest) -> &'static str {
"Hello world!"
}
fn main() {
::std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let sys = actix::System::new("hello-world");
server::new(|| {
App::new()
// enable logger
.middleware(middleware::Logger::default())
.resource("/index.html", |r| r.f(|_| "Hello world!"))
.resource("/", |r| r.f(index))
}).bind("127.0.0.1:8080")
.unwrap()
.start();
println!("Started http server: 127.0.0.1:8080");
let _ = sys.run();
}
网友评论