1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 06:57:43 +02:00

perf: remove unnecessary allocation when writing http dates (#3261)

This commit is contained in:
Rob Ede
2024-02-07 03:47:30 +00:00
committed by GitHub
parent 7e4e12b0aa
commit 1e2ef6f92f
29 changed files with 75 additions and 61 deletions

View File

@ -0,0 +1,20 @@
use std::time::SystemTime;
use actix_http::header::HttpDate;
use divan::{black_box, AllocProfiler, Bencher};
#[global_allocator]
static ALLOC: AllocProfiler = AllocProfiler::system();
#[divan::bench]
fn date_formatting(b: Bencher<'_, '_>) {
let now = SystemTime::now();
b.bench(|| {
black_box(HttpDate::from(black_box(now)).to_string());
})
}
fn main() {
divan::main();
}