Skip to content

Commit

Permalink
Add await-call-tree benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
tmandry committed Oct 15, 2019
1 parent e48e0a0 commit ca5840a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions collector/benchmarks/README.md
Expand Up @@ -64,6 +64,10 @@ These are artificial programs that stress one particular aspect of the
compiler. Some are entirely artificial, and some are extracted from real
programs.

- **await-call-tree**: A tree of async fns that await each other, creating a
large type composed of many repeated `impl Future` types. Such types caused
[poor performance](https://github.com/rust-lang/rust/issues/65147) in the
past.
- **coercions**: Contains a static array with 65,536 string literals, which
caused [poor performance](https://github.com/rust-lang/rust/issues/32278) in
the past.
Expand Down
6 changes: 6 additions & 0 deletions collector/benchmarks/await-call-tree/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions collector/benchmarks/await-call-tree/Cargo.toml
@@ -0,0 +1,5 @@
[package]
name = "await-call-tree"
version = "0.1.0"
authors = ["Tyler Mandry <tmandry@gmail.com>"]
edition = "2018"
22 changes: 22 additions & 0 deletions collector/benchmarks/await-call-tree/src/lib.rs
@@ -0,0 +1,22 @@
#![type_length_limit="15000000"]
#![allow(unused)]

macro_rules! mk_async_fn {
($f:ident $g:ident) => {
async fn $g() -> i32 {
$f().await;
$f().await;
$f().await
}
}
}

async fn a() -> i32 { 1 }

mk_async_fn!(a b);
mk_async_fn!(b c);
mk_async_fn!(c d);
mk_async_fn!(d e);
mk_async_fn!(e f);
mk_async_fn!(f g);
mk_async_fn!(g h);

0 comments on commit ca5840a

Please sign in to comment.