jester
jester copied to clipboard
patterns in Jester are very slow
patterns in Jester are very slow compared to normal routes i mean by more than half when i benchmark with wrk that should be negligible get "/hello/@name": let val = @"name" resp val
I took a look at patterns.nim and in the check() function found this line of code:
return s.substr(i, cutTo) == n.text
This means that a partial copy of a string is made every time the check() function is called. For better performance a string comparison function should be used instead (zero-copy). In C I would use strncmp starting at position i with the length of cutTo, but as I'm new to Nim I'm not sure what the best way to do this is (string slices don't appear to be zero-copy from my research).
Zero-copy string slices for Nim are in the works though.
strutils.continuesWith()
seems to fit.