@@ -72,6 +72,106 @@ fn criterion_benchmark(c: &mut Criterion) {
7272 ) ;
7373 }
7474 group. finish ( ) ;
75+
76+ let mut group = c. benchmark_group ( "map save" ) ;
77+ for size in & sizes {
78+ group. throughput ( criterion:: Throughput :: Elements ( * size) ) ;
79+ group. bench_with_input ( BenchmarkId :: new ( "repeated put" , size) , size, |b, & size| {
80+ b. iter_batched (
81+ || repeated_put ( size) ,
82+ |mut doc| doc. save ( ) ,
83+ criterion:: BatchSize :: LargeInput ,
84+ )
85+ } ) ;
86+ group. bench_with_input (
87+ BenchmarkId :: new ( "repeated increment" , size) ,
88+ size,
89+ |b, & size| {
90+ b. iter_batched (
91+ || repeated_increment ( size) ,
92+ |mut doc| doc. save ( ) ,
93+ criterion:: BatchSize :: LargeInput ,
94+ )
95+ } ,
96+ ) ;
97+
98+ group. throughput ( criterion:: Throughput :: Elements ( * size) ) ;
99+ group. bench_with_input (
100+ BenchmarkId :: new ( "increasing put" , size) ,
101+ size,
102+ |b, & size| {
103+ b. iter_batched (
104+ || increasing_put ( size) ,
105+ |mut doc| doc. save ( ) ,
106+ criterion:: BatchSize :: LargeInput ,
107+ )
108+ } ,
109+ ) ;
110+
111+ group. throughput ( criterion:: Throughput :: Elements ( * size) ) ;
112+ group. bench_with_input (
113+ BenchmarkId :: new ( "decreasing put" , size) ,
114+ size,
115+ |b, & size| {
116+ b. iter_batched (
117+ || decreasing_put ( size) ,
118+ |mut doc| doc. save ( ) ,
119+ criterion:: BatchSize :: LargeInput ,
120+ )
121+ } ,
122+ ) ;
123+ }
124+ group. finish ( ) ;
125+
126+ let mut group = c. benchmark_group ( "map load" ) ;
127+ for size in & sizes {
128+ group. throughput ( criterion:: Throughput :: Elements ( * size) ) ;
129+ group. bench_with_input ( BenchmarkId :: new ( "repeated put" , size) , size, |b, & size| {
130+ b. iter_batched (
131+ || repeated_put ( size) . save ( ) ,
132+ |bytes| Automerge :: load ( & bytes) . unwrap ( ) ,
133+ criterion:: BatchSize :: LargeInput ,
134+ )
135+ } ) ;
136+ group. bench_with_input (
137+ BenchmarkId :: new ( "repeated increment" , size) ,
138+ size,
139+ |b, & size| {
140+ b. iter_batched (
141+ || repeated_increment ( size) . save ( ) ,
142+ |bytes| Automerge :: load ( & bytes) . unwrap ( ) ,
143+ criterion:: BatchSize :: LargeInput ,
144+ )
145+ } ,
146+ ) ;
147+
148+ group. throughput ( criterion:: Throughput :: Elements ( * size) ) ;
149+ group. bench_with_input (
150+ BenchmarkId :: new ( "increasing put" , size) ,
151+ size,
152+ |b, & size| {
153+ b. iter_batched (
154+ || increasing_put ( size) . save ( ) ,
155+ |bytes| Automerge :: load ( & bytes) . unwrap ( ) ,
156+ criterion:: BatchSize :: LargeInput ,
157+ )
158+ } ,
159+ ) ;
160+
161+ group. throughput ( criterion:: Throughput :: Elements ( * size) ) ;
162+ group. bench_with_input (
163+ BenchmarkId :: new ( "decreasing put" , size) ,
164+ size,
165+ |b, & size| {
166+ b. iter_batched (
167+ || decreasing_put ( size) . save ( ) ,
168+ |bytes| Automerge :: load ( & bytes) . unwrap ( ) ,
169+ criterion:: BatchSize :: LargeInput ,
170+ )
171+ } ,
172+ ) ;
173+ }
174+ group. finish ( ) ;
75175}
76176
77177criterion_group ! ( benches, criterion_benchmark) ;
0 commit comments