【Rust日报】2019-09-02 - Rocket和Actix-Web的异步性能测试

本文对比了Rocket的同步和异步分支以及Actix-Web的性能,结果显示异步Rocket性能显著提升,但仍不及Actix-Web。同时还介绍了rustversion库用于条件编译,mobi-rs库解析.mobi文件,以及Persy事务性存储引擎。
摘要由CSDN通过智能技术生成

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
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值