forked from crepererum/rust_issue_87012
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vary-async-depth.sh
executable file
·62 lines (47 loc) · 1.25 KB
/
vary-async-depth.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -euo pipefail
shopt -s extglob
echo "# Varying number of async functions called
| # of async fns | Item | Self time | % of total time | Time | Item count | Incremental result hashing time |
|---|--------------------------------------------------|-----------|-----------------|----------|------------|---------------------------------|" > vary-async-depth-results.md
for MAX_DEPTH in {1..30}
do
echo "pub async fn entry_point() {
let x = X$MAX_DEPTH::new();
x.f().await;
}
async fn term_async() -> u32 {
1
}
fn term_sync() -> u32 {
1
}
struct X0 {}
impl X0 {
fn new() -> Self {
Self {}
}
async fn f(&self) -> u32 {
term_sync() + term_async().await
}
}" > helper_crate/src/lib.rs
for DEPTH in $( seq 1 $MAX_DEPTH )
do
echo "struct X$DEPTH {
x: X$(($DEPTH - 1)),
}
impl X$DEPTH {
fn new() -> Self {
Self {
x: X$(($DEPTH - 1))::new(),
}
}
async fn f(&self) -> u32 {
term_sync() + self.x.f().await
}
}" >> helper_crate/src/lib.rs
done
RESULTS=$(./test.sh)
echo "| $MAX_DEPTH $RESULTS" >> vary-async-depth-results.md
done
git checkout helper_crate/src/lib.rs