You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used viztracer to analyze the performance of HashModel and BaseModel, and found that the time difference between the two was hundreds of times when the model was generated, and a large number of Deepcopies were generated when the HashModel was generated, but I could not locate the problem, Is the pydantic v1 version causing the problem?
create model cost:
BaseModel ~= 3us
HashModel ~= 700us
from pydantic import BaseModel
from redis_om import HashModel
class TaskStatisticalModel(BaseModel):
task_uuid: str = ""
parallel_task: str = ""
is_alarm: int = 0
class TaskStatisticalModel2(HashModel):
task_uuid: str = ""
parallel_task: str = ""
is_alarm: int = 0
def add_redis_model():
TaskStatisticalModel2()
def add_base_model():
TaskStatisticalModel()
def test_redis_model(number=10):
for i in range(number):
add_redis_model()
def test_base_model(number=10):
for i in range(number):
add_base_model()
if __name__ == '__main__':
num = 10
test_redis_model(num)
test_base_model(num)
use viztracer
viztracer demo.py
# wait
vizviewer result.json
search:
"add_redis_model" => hash_model
"add_base_model" => base model
The text was updated successfully, but these errors were encountered:
I used viztracer to analyze the performance of HashModel and BaseModel, and found that the time difference between the two was hundreds of times when the model was generated, and a large number of Deepcopies were generated when the HashModel was generated, but I could not locate the problem, Is the pydantic v1 version causing the problem?
create model cost:
BaseModel ~= 3us
HashModel ~= 700us
python:3.11
viztracer==0.16.3
redis-om==0.3.1
redis == 5.0.6
eg: demo.py
use viztracer
search:
"add_redis_model" => hash_model
"add_base_model" => base model
The text was updated successfully, but these errors were encountered: