@@ -16,6 +16,7 @@ void main() async {
16
16
await PutQueued ().report ();
17
17
await RunInTx ().report ();
18
18
await RunInTxAsync ().report ();
19
+ await RunAsync ().report ();
19
20
}
20
21
21
22
class Put extends DbBenchmark {
@@ -106,7 +107,10 @@ class RunInTx extends DbBenchmark {
106
107
107
108
@override
108
109
void runIteration (int i) {
109
- store.runInTransaction (TxMode .write, () => items.forEach (box.put));
110
+ store.runInTransaction (TxMode .write, () {
111
+ box.putMany (items);
112
+ return box.getAll ();
113
+ });
110
114
}
111
115
}
112
116
@@ -116,11 +120,27 @@ class RunInTxAsync extends DbBenchmark {
116
120
RunInTxAsync () : super ('$RunInTxAsync ' );
117
121
118
122
@override
119
- Future <void > runIteration (int iteration) {
123
+ Future <List < TestEntity >> runIteration (int iteration) async {
120
124
return store.runInTransactionAsync (TxMode .write,
121
- (Store store, List <TestEntity > items ) {
125
+ (Store store, List <TestEntity > param ) {
122
126
final box = store.box <TestEntity >();
123
- items.forEach (box.put);
127
+ box.putMany (param);
128
+ return box.getAll ();
129
+ }, items);
130
+ }
131
+ }
132
+
133
+ class RunAsync extends DbBenchmark {
134
+ final items = prepareTestEntities (count, assignedIds: true );
135
+
136
+ RunAsync () : super ('$RunAsync ' );
137
+
138
+ @override
139
+ Future <List <TestEntity >> runIteration (int iteration) {
140
+ return store.runAsync ((Store store, List <TestEntity > param) {
141
+ final box = store.box <TestEntity >();
142
+ box.putMany (param);
143
+ return box.getAll ();
124
144
}, items);
125
145
}
126
146
}
0 commit comments