@@ -12,18 +12,18 @@ use deltachat::{
12
12
} ;
13
13
use tempfile:: tempdir;
14
14
15
- async fn recv_all_emails ( context : Context ) -> Context {
15
+ async fn recv_all_emails ( context : Context , iteration : u32 ) -> Context {
16
16
for i in 0 ..100 {
17
17
let imf_raw = format ! (
18
18
"Subject: Benchmark
19
- Message-ID: Mr.OssSYnOFkhR .{i}@testrun.org
19
+ Message-ID: Mr.{iteration} .{i}@testrun.org
20
20
Date: Sat, 07 Dec 2019 19:00:27 +0000
21
21
To: alice@example.com
22
22
From: sender@testrun.org
23
23
Chat-Version: 1.0
24
24
Chat-Disposition-Notification-To: sender@testrun.org
25
25
Chat-User-Avatar: 0
26
- In-Reply-To: Mr.OssSYnOFkhR .{i_dec}@testrun.org
26
+ In-Reply-To: Mr.{iteration} .{i_dec}@testrun.org
27
27
MIME-Version: 1.0
28
28
29
29
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
@@ -41,25 +41,24 @@ Hello {i}",
41
41
42
42
/// Receive 100 emails that remove charlie@example.com and add
43
43
/// him back
44
- async fn recv_groupmembership_emails ( context : Context ) -> Context {
44
+ async fn recv_groupmembership_emails ( context : Context , iteration : u32 ) -> Context {
45
45
for i in 0 ..50 {
46
46
let imf_raw = format ! (
47
47
"Subject: Benchmark
48
- Message-ID: Gr.OssSYnOFkhR .{i}@testrun.org
48
+ Message-ID: Gr.{iteration}.ADD .{i}@testrun.org
49
49
Date: Sat, 07 Dec 2019 19:00:27 +0000
50
50
To: alice@example.com, b@example.com, c@example.com, d@example.com, e@example.com, f@example.com
51
51
From: sender@testrun.org
52
52
Chat-Version: 1.0
53
53
Chat-Disposition-Notification-To: sender@testrun.org
54
54
Chat-User-Avatar: 0
55
55
Chat-Group-Member-Added: charlie@example.com
56
- In-Reply-To: Gr.OssSYnOFkhR .{i_dec}@testrun.org
56
+ In-Reply-To: Gr.{iteration}.REMOVE .{i_dec}@testrun.org
57
57
MIME-Version: 1.0
58
58
59
59
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
60
60
61
61
Hello {i}" ,
62
- i = i,
63
62
i_dec = i - 1 ,
64
63
) ;
65
64
receive_imf ( & context, black_box ( imf_raw. as_bytes ( ) ) , false )
@@ -68,22 +67,20 @@ Hello {i}",
68
67
69
68
let imf_raw = format ! (
70
69
"Subject: Benchmark
71
- Message-ID: Gr.OssSYnOFkhR .{i}@testrun.org
70
+ Message-ID: Gr.{iteration}.REMOVE .{i}@testrun.org
72
71
Date: Sat, 07 Dec 2019 19:00:27 +0000
73
72
To: alice@example.com, b@example.com, c@example.com, d@example.com, e@example.com, f@example.com
74
73
From: sender@testrun.org
75
74
Chat-Version: 1.0
76
75
Chat-Disposition-Notification-To: sender@testrun.org
77
76
Chat-User-Avatar: 0
78
77
Chat-Group-Member-Removed: charlie@example.com
79
- In-Reply-To: Gr.OssSYnOFkhR.{i_dec }@testrun.org
78
+ In-Reply-To: Gr.{iteration}.ADD.{i }@testrun.org
80
79
MIME-Version: 1.0
81
80
82
81
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
83
82
84
- Hello {i}" ,
85
- i = i,
86
- i_dec = i - 1 ,
83
+ Hello {i}"
87
84
) ;
88
85
receive_imf ( & context, black_box ( imf_raw. as_bytes ( ) ) , false )
89
86
. await
@@ -129,11 +126,13 @@ fn criterion_benchmark(c: &mut Criterion) {
129
126
group. bench_function ( "Receive 100 simple text msgs" , |b| {
130
127
let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
131
128
let context = rt. block_on ( create_context ( ) ) ;
129
+ let mut i = 0 ;
132
130
133
131
b. to_async ( & rt) . iter ( || {
134
132
let ctx = context. clone ( ) ;
133
+ i += 1 ;
135
134
async move {
136
- recv_all_emails ( black_box ( ctx) ) . await ;
135
+ recv_all_emails ( black_box ( ctx) , i ) . await ;
137
136
}
138
137
} ) ;
139
138
} ) ;
@@ -142,11 +141,13 @@ fn criterion_benchmark(c: &mut Criterion) {
142
141
|b| {
143
142
let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
144
143
let context = rt. block_on ( create_context ( ) ) ;
144
+ let mut i = 0 ;
145
145
146
146
b. to_async ( & rt) . iter ( || {
147
147
let ctx = context. clone ( ) ;
148
+ i += 1 ;
148
149
async move {
149
- recv_groupmembership_emails ( black_box ( ctx) ) . await ;
150
+ recv_groupmembership_emails ( black_box ( ctx) , i ) . await ;
150
151
}
151
152
} ) ;
152
153
} ,
0 commit comments