Skip to content

Update criterion to 0.6, Update rust-version to 1.66, fix warnings. #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

- Update `criterion` to v0.6.
- Update to `rust-version` 1.66.

# Version 2.4.0

- Make it so the `Exit` filter can be created without passing ownership of the
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name = "async-io"
version = "2.4.0"
authors = ["Stjepan Glavina <[email protected]>"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.66"
description = "Async I/O and timers"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/smol-rs/async-io"
Expand Down Expand Up @@ -44,7 +44,7 @@ windows-sys = { version = "0.59.0", features = ["Win32_Foundation"] }
async-channel = "2.0.0"
async-net = "2.0.0"
blocking = "1"
criterion = { version = "0.4", default-features = false, features = ["cargo_bench_support"] }
criterion = { version = "0.6", default-features = false, features = ["cargo_bench_support"] }
getrandom = "0.3"
signal-hook = "0.3"
tempfile = "3"
Expand Down
15 changes: 8 additions & 7 deletions benches/io.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Benchmarks for a variety of I/O operations.

use async_io::Async;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main, Criterion};
use futures_lite::{future, prelude::*};
use std::hint::black_box;
use std::net::{Ipv4Addr, SocketAddr, TcpListener, TcpStream, UdpSocket};

/// Block on a future, either using the I/O driver or simple parking.
Expand Down Expand Up @@ -32,7 +33,7 @@ fn read_and_write(b: &mut Criterion) {
(listener, reader, writer)
};

group.bench_function(format!("TcpStream.{}", driver_name), move |b| {
group.bench_function(format!("TcpStream.{driver_name}"), move |b| {
let (_listener, mut reader, mut writer) = init_reader_writer();
let mut buf = vec![0x42; TCP_AMOUNT];

Expand All @@ -55,7 +56,7 @@ fn read_and_write(b: &mut Criterion) {
use std::os::unix::net::UnixStream;
const UNIX_AMOUNT: usize = 1024;

group.bench_function(format!("UnixStream.{}", driver_name), |b| {
group.bench_function(format!("UnixStream.{driver_name}"), |b| {
let (mut reader, mut writer) = Async::<UnixStream>::pair().unwrap();
let mut buf = vec![0x42; UNIX_AMOUNT];

Expand All @@ -79,7 +80,7 @@ fn connect_and_accept(c: &mut Criterion) {

for (driver_name, exec) in [("Undriven", false), ("Driven", true)] {
// Benchmark the TCP streams.
group.bench_function(format!("TcpStream.{}", driver_name), move |b| {
group.bench_function(format!("TcpStream.{driver_name}"), move |b| {
let socket_addr =
SocketAddr::new("127.0.0.1".parse::<Ipv4Addr>().unwrap().into(), 12345);
let listener = Async::<TcpListener>::bind(socket_addr).unwrap();
Expand All @@ -105,10 +106,10 @@ fn connect_and_accept(c: &mut Criterion) {
getrandom::fill(&mut id).unwrap();
let id = u64::from_ne_bytes(id);

let socket_addr = format!("/tmp/async-io-bench-{}.sock", id);
let socket_addr = format!("/tmp/async-io-bench-{id}.sock");
let listener = Async::<UnixListener>::bind(&socket_addr).unwrap();

group.bench_function(format!("UnixStream.{}", driver_name), |b| {
group.bench_function(format!("UnixStream.{driver_name}"), |b| {
b.iter(|| {
block_on(
async {
Expand Down Expand Up @@ -142,7 +143,7 @@ fn udp_send_recv(c: &mut Criterion) {
let mut buf = vec![0x42; UDP_AMOUNT];

for (driver_name, exec) in [("Undriven", false), ("Driven", true)] {
group.bench_function(format!("UdpSocket.{}", driver_name), |b| {
group.bench_function(format!("UdpSocket.{driver_name}"), |b| {
b.iter(|| {
let buf = &mut buf;

Expand Down
6 changes: 4 additions & 2 deletions benches/timer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Benchmarks for registering timers.

use std::hint::black_box;

use async_io::Timer;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use criterion::{criterion_group, criterion_main, Criterion};
use futures_lite::future;
use std::time::Duration;

Expand All @@ -24,7 +26,7 @@ fn register_timer(c: &mut Criterion) {

// Benchmark registering a timer.
group.bench_function(
format!("register_timer.({} previous timers)", prev_timer_count),
format!("register_timer.({prev_timer_count} previous timers)"),
|b| {
b.iter(|| {
let timer = make_timer();
Expand Down
2 changes: 1 addition & 1 deletion examples/linux-inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn main() -> std::io::Result<()> {
// Wait for events in a loop and print them on the screen.
loop {
for event in unsafe { inotify.read_with_mut(read_op).await? } {
println!("{:?}", event);
println!("{event:?}");
}
}
})
Expand Down