@@ -51,39 +51,34 @@ fn bench_version<F>(
51
51
{
52
52
group. bench_function ( format ! ( "{} - Import" , name) , |b| {
53
53
b. iter_custom ( |iters| {
54
- let mut total = std :: time :: Duration :: ZERO ;
54
+ let start = Instant :: now ( ) ;
55
55
for _ in 0 ..iters {
56
- let start = Instant :: now ( ) ;
57
56
let doc = LoroDoc :: new ( ) ;
58
57
doc. import ( black_box ( input) ) . unwrap ( ) ;
59
- total += start. elapsed ( ) ;
60
58
black_box ( doc) ;
61
59
}
62
- total
60
+ start . elapsed ( )
63
61
} ) ;
64
62
} ) ;
65
63
66
64
group. bench_function ( format ! ( "{} - Import+GetAllValues" , name) , |b| {
67
65
b. iter_custom ( |iters| {
68
- let mut total = std :: time :: Duration :: ZERO ;
66
+ let start = Instant :: now ( ) ;
69
67
for _ in 0 ..iters {
70
- let start = Instant :: now ( ) ;
71
68
let doc = LoroDoc :: new ( ) ;
72
69
doc. import ( black_box ( input) ) . unwrap ( ) ;
73
70
let value = doc. get_deep_value ( ) ;
74
- total += start. elapsed ( ) ;
75
71
black_box ( doc) ;
76
72
black_box ( value) ;
77
73
}
78
- total
74
+ start . elapsed ( )
79
75
} ) ;
80
76
} ) ;
81
77
82
78
group. bench_function ( format ! ( "{} - Import+GetAllValues+Edit" , name) , |b| {
83
79
b. iter_custom ( |iters| {
84
- let mut total = std :: time :: Duration :: ZERO ;
80
+ let start = Instant :: now ( ) ;
85
81
for _ in 0 ..iters {
86
- let start = Instant :: now ( ) ;
87
82
let doc = LoroDoc :: new ( ) ;
88
83
doc. import ( black_box ( input) ) . unwrap ( ) ;
89
84
let value = doc. get_deep_value ( ) ;
@@ -93,19 +88,18 @@ fn bench_version<F>(
93
88
let text = cell. insert_container ( "source" , LoroText :: new ( ) ) . unwrap ( ) ;
94
89
text. insert ( 0 , "Hello world!" ) . unwrap ( ) ;
95
90
doc. commit ( ) ;
96
- total += start. elapsed ( ) ;
97
91
black_box ( doc) ;
98
92
black_box ( value) ;
93
+ black_box ( text) ;
99
94
}
100
- total
95
+ start . elapsed ( )
101
96
} ) ;
102
97
} ) ;
103
98
104
99
group. bench_function ( format ! ( "{} - Import+GetAllValues+Edit+Export" , name) , |b| {
105
100
b. iter_custom ( |iters| {
106
- let mut total = std :: time :: Duration :: ZERO ;
101
+ let start = Instant :: now ( ) ;
107
102
for _ in 0 ..iters {
108
- let start = Instant :: now ( ) ;
109
103
let doc = LoroDoc :: new ( ) ;
110
104
doc. import ( black_box ( input) ) . unwrap ( ) ;
111
105
let value = doc. get_deep_value ( ) ;
@@ -117,11 +111,11 @@ fn bench_version<F>(
117
111
doc. commit ( ) ;
118
112
let snapshot = export_fn ( & doc) ;
119
113
black_box ( snapshot) ;
120
- total += start. elapsed ( ) ;
121
114
black_box ( doc) ;
122
115
black_box ( value) ;
116
+ black_box ( text) ;
123
117
}
124
- total
118
+ start . elapsed ( )
125
119
} ) ;
126
120
} ) ;
127
121
}
@@ -136,39 +130,34 @@ fn bench_version_016<F>(
136
130
{
137
131
group. bench_function ( format ! ( "{} - Import" , name) , |b| {
138
132
b. iter_custom ( |iters| {
139
- let mut total = std :: time :: Duration :: ZERO ;
133
+ let start = Instant :: now ( ) ;
140
134
for _ in 0 ..iters {
141
- let start = Instant :: now ( ) ;
142
135
let doc = loro_016:: LoroDoc :: new ( ) ;
143
136
doc. import ( black_box ( input) ) . unwrap ( ) ;
144
- total += start. elapsed ( ) ;
145
137
black_box ( doc) ;
146
138
}
147
- total
139
+ start . elapsed ( )
148
140
} ) ;
149
141
} ) ;
150
142
151
143
group. bench_function ( format ! ( "{} - Import+GetAllValues" , name) , |b| {
152
144
b. iter_custom ( |iters| {
153
- let mut total = std :: time :: Duration :: ZERO ;
145
+ let start = Instant :: now ( ) ;
154
146
for _ in 0 ..iters {
155
- let start = Instant :: now ( ) ;
156
147
let doc = loro_016:: LoroDoc :: new ( ) ;
157
148
doc. import ( black_box ( input) ) . unwrap ( ) ;
158
149
let value = doc. get_deep_value ( ) ;
159
- total += start. elapsed ( ) ;
160
150
black_box ( doc) ;
161
151
black_box ( value) ;
162
152
}
163
- total
153
+ start . elapsed ( )
164
154
} ) ;
165
155
} ) ;
166
156
167
157
group. bench_function ( format ! ( "{} - Import+GetAllValues+Edit" , name) , |b| {
168
158
b. iter_custom ( |iters| {
169
- let mut total = std :: time :: Duration :: ZERO ;
159
+ let start = Instant :: now ( ) ;
170
160
for _ in 0 ..iters {
171
- let start = Instant :: now ( ) ;
172
161
let doc = loro_016:: LoroDoc :: new ( ) ;
173
162
doc. import ( black_box ( input) ) . unwrap ( ) ;
174
163
let value = doc. get_deep_value ( ) ;
@@ -180,19 +169,18 @@ fn bench_version_016<F>(
180
169
. unwrap ( ) ;
181
170
text. insert ( 0 , "Hello world!" ) . unwrap ( ) ;
182
171
doc. commit ( ) ;
183
- total += start. elapsed ( ) ;
184
172
black_box ( doc) ;
185
173
black_box ( value) ;
174
+ black_box ( text) ;
186
175
}
187
- total
176
+ start . elapsed ( )
188
177
} ) ;
189
178
} ) ;
190
179
191
180
group. bench_function ( format ! ( "{} - Import+GetAllValues+Edit+Export" , name) , |b| {
192
181
b. iter_custom ( |iters| {
193
- let mut total = std :: time :: Duration :: ZERO ;
182
+ let start = Instant :: now ( ) ;
194
183
for _ in 0 ..iters {
195
- let start = Instant :: now ( ) ;
196
184
let doc = loro_016:: LoroDoc :: new ( ) ;
197
185
doc. import ( black_box ( input) ) . unwrap ( ) ;
198
186
let value = doc. get_deep_value ( ) ;
@@ -206,11 +194,11 @@ fn bench_version_016<F>(
206
194
doc. commit ( ) ;
207
195
let snapshot = export_fn ( & doc) ;
208
196
black_box ( snapshot) ;
209
- total += start. elapsed ( ) ;
210
197
black_box ( doc) ;
211
198
black_box ( value) ;
199
+ black_box ( text) ;
212
200
}
213
- total
201
+ start . elapsed ( )
214
202
} ) ;
215
203
} ) ;
216
204
}
0 commit comments