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-
151"""Tests for the MongoDB ODM Performance Benchmark Spec.
162
173See https://github.com/mongodb/specifications/blob/master/source/benchmarking/odm-benchmarking.md
@@ -200,9 +186,10 @@ def after(self):
200186class TestSmallFlatDocUpdate (SmallFlatDocTest , TestCase ):
201187 def setUp (self ):
202188 super ().setUp ()
189+ self .models = []
203190 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 )
206193 self .data_size = len (encode ({"field1" : "updated_value0" })) * NUM_DOCS
207194 self .iteration = 0
208195
@@ -220,9 +207,11 @@ class TestSmallFlatDocFilterById(SmallFlatDocTest, TestCase):
220207 def setUp (self ):
221208 super ().setUp ()
222209 self .ids = []
210+ models = []
223211 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 ]
226215
227216 def do_task (self ):
228217 for _id in self .ids :
0 commit comments