Suggestion to improve performance

Sep 19, 2011 at 6:02 PM

Hi Roman,

by replace all-call to EnumType.HasFlag (flag) with (EnumType & flag) != 0,  performance improve 100-400%

reduceProduction.LValue.Flags.HasFlag(TermFlags.IsTransient)

vs

((reduceProduction.LValue.Flags & TermFlags.IsListContainer) != 0)

C#:  input: 60K lines, 200K tokens, release-mode

with hasFlag: 3233ms
without hasFlag: 1472ms

ExpressionEvaluatorGrammar: input: 190k tokens, release-mode

with hasFlag: 1802ms
without hasFlag: 384ms

hope it help :]

Coordinator
Sep 19, 2011 at 6:16 PM

hmmm... that's interesting observation. I thought HasFlag is "native" implementation, and is equivalent to "&", but it looks like it's not...

thanks for the tip!

 

Sep 26, 2011 at 11:50 AM
Edited Sep 26, 2011 at 2:04 PM

I found the same improvement, Irony is 3 times faster with my custom grammar, average with HasFlag : 4.5ms, after replacing all occurences of HasFlag with a bitwise operation : 1.45ms. It takes 2 minutes to fix it.

BTW, thanks a lot, Irony is awesome, it's such a pleasure to work with it !

 

Coordinator
Sep 26, 2011 at 5:24 PM

yea, I already measured it, just the operation itself - HasFlag is about 500 times slower than bitwise operation. Fixed it, will be in the next code drop

thanks!