Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions benchmarks/django/simple/test_i.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
7 changes: 2 additions & 5 deletions benchmarks/django/simple/test_j.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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}")