Skip to content

Improve speed of TRCReader - #1893

Merged
zariiii9003 merged 1 commit into
hardbyte:mainfrom
TheTrueAI:patch-1
Nov 26, 2024
Merged

Improve speed of TRCReader#1893
zariiii9003 merged 1 commit into
hardbyte:mainfrom
TheTrueAI:patch-1

Conversation

@TheTrueAI

@TheTrueAITheTrueAI commented Nov 10, 2024

Copy link
Copy Markdown
Contributor

Optimized TRCReader for speed, mainly for TRC files v2.x. According to cProfile it's double as fast now.

Comment threadcan/io/trc.py
Comment threadcan/io/trc.py Outdated
super().__init__(file, mode="r")
self.file_version = TRCFileVersion.UNKNOWN
self.start_time: Optional[datetime] = None
self.start_time: float = 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute is public, so changing the type could break user code. I'd suggest creating a private float attribute _timestamp and a property timestamp, that returns a datetime instance like before.

Otherwise this looks good to me.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Changed it

@zariiii9003zariiii9003 mentioned this pull request Nov 23, 2024
Rewrote some lines in the TRCReader to optimize for speed, mainly for TRC files v2.x. According to cProfile it's double as fast now.

@zariiii9003zariiii9003 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you

@zariiii9003
zariiii9003 merged commit 226e040 into hardbyte:mainNov 26, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@TheTrueAI@zariiii9003