Rocket和Actix-Web的异步性能测试
Rust目前最火的两个web框架就是Actix-Web和Rocket, 众所周知,Rocket的优势在于易用性,Actix-web在于性能,最近,Rocket的人员正在迁移到异步后端。因此,作者想看看异步分支和主分支如何的性能如何同时和Actix-Web进行比较是很有趣的。
测试使用的项目
用Rocket编写的hello world应用程序
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[get("/")]
fn index() -> String {
"Hello, world!".to_string()
}
fn main() {
rocket::ignite().mount("/", routes![index]).launch();
}
Cargo.toml的差异(同步和异步)
[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", branch = "async" }
同步
[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", branch = "master" }
下面的程序用于测试Actix-Web
use actix_web::{web, App, HttpServer, Responder};
fn index() -> impl Responder {
"Hello, World".to_string()
}
fn main() -> std