-
Notifications
You must be signed in to change notification settings - Fork 3
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
Found how to improve performance of the access operators #7
Comments
planetis-m
changed the title
Found how to improve performace of the access operators
Found how to improve performance of the access operators
May 1, 2022
Same issue as: nim-lang/Nim#18339 |
This change in myParseBin did not improve performance versus making template longData(s: String): untyped = s.p
template shortData(s: String): untyped =
cast[ptr UncheckedArray[char]](addr s.short.data[0])
if s.isLong:
while i < last:
case s.longData[i]
of '_': discard
of '0'..'1':
output = output shl 1 or T(ord(s.longData[i]) - ord('0'))
foundDigit = true
else: break
inc(i)
else:
while i < last:
case s.shortData[i]
of '_': discard
of '0'..'1':
output = output shl 1 or T(ord(s.shortData[i]) - ord('0'))
foundDigit = true
else: break
inc(i) Results:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently there's a consisted 50% decrease in performance (0.22ms -> 0.44ms) for both short and long strings compared to std.string in the parseBinInt benchmark. Tested with gcc and clang. Using templates instead of procs for
[]
, it drops down to ~26% (0.3ms).The text was updated successfully, but these errors were encountered: