1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-30 00:14:58 +02:00

Use immutable reference of service state. Update awc dns resolver. (#1905)

This commit is contained in:
fakeshadow
2021-02-06 17:00:40 -08:00
committed by GitHub
parent 20cf0094e5
commit 41bc04b1c4
65 changed files with 497 additions and 538 deletions

View File

@ -68,7 +68,7 @@ impl<T: Responder> Responder for OptionResponder<T> {
}
fn future_responder(c: &mut Criterion) {
let rt = actix_rt::System::new("test");
let rt = actix_rt::System::new();
let req = TestRequest::default().to_http_request();
c.bench_function("future_responder", move |b| {
@ -91,7 +91,7 @@ fn future_responder(c: &mut Criterion) {
}
fn responder(c: &mut Criterion) {
let rt = actix_rt::System::new("test");
let rt = actix_rt::System::new();
let req = TestRequest::default().to_http_request();
c.bench_function("responder", move |b| {
b.iter_custom(|_| {

View File

@ -29,7 +29,7 @@ const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
fn bench_async_burst(c: &mut Criterion) {
// We are using System here, since Runtime requires preinitialized tokio
// Maybe add to actix_rt docs
let rt = actix_rt::System::new("test");
let rt = actix_rt::System::new();
let srv = rt.block_on(async {
test::start(|| {

View File

@ -25,7 +25,7 @@ pub fn bench_async_service<S>(c: &mut Criterion, srv: S, name: &str)
where
S: Service<ServiceRequest, Response = ServiceResponse, Error = Error> + 'static,
{
let rt = actix_rt::System::new("test");
let rt = actix_rt::System::new();
let srv = Rc::new(RefCell::new(srv));
let req = TestRequest::default().to_srv_request();
@ -67,7 +67,7 @@ async fn index(req: ServiceRequest) -> Result<ServiceResponse, Error> {
// Sample results on MacBook Pro '14
// time: [2.0724 us 2.1345 us 2.2074 us]
fn async_web_service(c: &mut Criterion) {
let rt = actix_rt::System::new("test");
let rt = actix_rt::System::new();
let srv = Rc::new(RefCell::new(rt.block_on(init_service(
App::new().service(web::service("/").finish(index)),
))));