From bde7536f19a340b2734bc2a166210e6d0c5d8a75 Mon Sep 17 00:00:00 2001 From: TheVeryDarkness <3266343194@qq.com> Date: Mon, 14 Oct 2024 21:26:40 +0800 Subject: [PATCH] Update benchmark to optimize away `Cursor`. --- benches/read.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benches/read.rs b/benches/read.rs index 1d85633..120193f 100644 --- a/benches/read.rs +++ b/benches/read.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use iof::{unwrap, InputStream, ReadInto, ReadOneInto}; use std::{ fs::{read_to_string, File}, - io::{self, BufRead, BufReader, Cursor, Read, Write}, + io::{self, BufRead, BufReader, Read, Write}, }; struct LazyWriter(std::ops::Range, Vec); @@ -126,11 +126,11 @@ const COUNT: usize = 0x10000 * 4; fn cursor(c: &mut Criterion) { { let s = unwrap!(read_to_string("benches/long.txt")); - (template("cursor-long", COUNT, || Cursor::new(&s)))(c); + (template("cursor-long", COUNT, || s.as_bytes()))(c); } { let s = unwrap!(read_to_string("benches/short.txt")); - (template("cursor-short", COUNT, || Cursor::new(&s)))(c); + (template("cursor-short", COUNT, || s.as_bytes()))(c); } }