Skip to content

Commit

Permalink
Revert "Refactor benchmark"
Browse files Browse the repository at this point in the history
This reverts commit fb54a52.
  • Loading branch information
Pliner committed Jan 15, 2024
1 parent fb54a52 commit 42224f0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions benchmarks/transaction_load_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
import dataclasses
import datetime
import decimal
import marshmallow_recipe as mr
import uuid

import marshmallow_recipe as mr
from typing import Annotated


@dataclasses.dataclass(frozen=True)
class Transaction:
id: uuid.UUID
created_at: datetime.datetime
processed_at: datetime.datetime | None
amount: decimal.Decimal
transaction_amount: decimal.Decimal
amount: decimal.Decimal = dataclasses.field(metadata=mr.decimal_metadata(places=4))
transaction_amount: Annotated[decimal.Decimal, mr.decimal_metadata(places=4)]


transaction = Transaction(
Expand All @@ -23,10 +24,8 @@ class Transaction:
amount=decimal.Decimal(42),
transaction_amount=decimal.Decimal(42),
)
transactions = [transaction] * 1024

# to warm up the lib caches
assert mr.load_many(Transaction, mr.dump_many([transaction] * 1024))

assert mr.load_many(Transaction, mr.dump_many(transactions))
assert mr.load_slim_many(Transaction, mr.dump_slim_many(transactions))
cProfile.run("mr.load_slim_many(Transaction, mr.dump_slim_many(transactions))", sort='tottime')
cProfile.run("mr.load_many(Transaction, mr.dump_many(transactions))", sort='tottime')
cProfile.run("mr.load_many(Transaction, mr.dump_many([transaction] * 1024))", sort='tottime')

0 comments on commit 42224f0

Please sign in to comment.