Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue with the redundancy operations #280

Open
yyzdtccjdtc opened this issue Jun 1, 2022 · 1 comment
Open

Performance issue with the redundancy operations #280

yyzdtccjdtc opened this issue Jun 1, 2022 · 1 comment

Comments

@yyzdtccjdtc
Copy link

self.line += (input[nin] == b'\n') as u64;

For this line of code, it will always update the value of self.line, even if the value of it does not change. This introduces some redundant operations.

If we change the code to this, we can eliminate these redundant operations.

if input[nin] == b'\n'{
     self.line += 1;
}

According to my tests with the ema example with this application (https://github.com/greyblake/ta-rs), the average execution time decreased from 2.74s to 2.68s, which is a 1.02x speedup.

Hope this information helps!

@BurntSushi
Copy link
Owner

Interesting. Seems like the compiler should be smarter than that here. But happy to make this change. PRs are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants