diff --git a/benchmarks/django/simple/test_i.py b/benchmarks/django/simple/test_i.py index acda7b6..6ed1743 100644 --- a/benchmarks/django/simple/test_i.py +++ b/benchmarks/django/simple/test_i.py @@ -8,23 +8,19 @@ import time from random import choice -from django.db import transaction from simple.models import Journal LEVEL_CHOICE = [10, 20, 30, 40, 50] - objs = list(Journal.objects.all()) count = len(objs) start = time.time() - -with transaction.atomic(): - for obj in objs: +for obj in objs: obj.level = choice(LEVEL_CHOICE) obj.text = f"{obj.text} Update" - obj.save() +Journal.objects.bulk_update(objs, ['level', 'text']) now = time.time() print(f"Django, I: Rows/sec: {count / (now - start): 10.2f}") diff --git a/benchmarks/django/simple/test_j.py b/benchmarks/django/simple/test_j.py index e417114..27eee43 100644 --- a/benchmarks/django/simple/test_j.py +++ b/benchmarks/django/simple/test_j.py @@ -8,7 +8,6 @@ import time from random import choice -from django.db import transaction from simple.models import Journal LEVEL_CHOICE = [10, 20, 30, 40, 50] @@ -18,12 +17,10 @@ count = len(objs) start = time.time() - -with transaction.atomic(): - for obj in objs: +for obj in objs: obj.level = choice(LEVEL_CHOICE) - obj.save(update_fields=["level"]) +Journal.objects.bulk_update(objs, ['level']) now = time.time() print(f"Django, J: Rows/sec: {count / (now - start): 10.2f}")