1
- # Copyright 2025-present MongoDB, Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
"""Tests for the MongoDB ODM Performance Benchmark Spec.
16
2
17
3
See https://github.com/mongodb/specifications/blob/master/source/benchmarking/odm-benchmarking.md
@@ -200,9 +186,10 @@ def after(self):
200
186
class TestSmallFlatDocUpdate (SmallFlatDocTest , TestCase ):
201
187
def setUp (self ):
202
188
super ().setUp ()
189
+ self .models = []
203
190
for doc in self .documents :
204
- SmallFlatModel . objects . create ( ** doc )
205
- self . models = list ( SmallFlatModel .objects .all () )
191
+ self . models . append ( SmallFlatModel ( ** doc ) )
192
+ SmallFlatModel .objects .bulk_create ( self . models )
206
193
self .data_size = len (encode ({"field1" : "updated_value0" })) * NUM_DOCS
207
194
self .iteration = 0
208
195
@@ -220,9 +207,11 @@ class TestSmallFlatDocFilterById(SmallFlatDocTest, TestCase):
220
207
def setUp (self ):
221
208
super ().setUp ()
222
209
self .ids = []
210
+ models = []
223
211
for doc in self .documents :
224
- model = SmallFlatModel .objects .create (** doc )
225
- self .ids .append (model .id )
212
+ models .append (SmallFlatModel (** doc ))
213
+ inserted = SmallFlatModel .objects .bulk_create (models )
214
+ self .ids = [model .id for model in inserted ]
226
215
227
216
def do_task (self ):
228
217
for _id in self .ids :
0 commit comments