Why is CharInSet faster than Case statement?

后端 未结 5 990
借酒劲吻你
借酒劲吻你 2020-12-05 11:26

I\'m perplexed. At CodeRage today, Marco Cantu said that CharInSet was slow and I should try a Case statement instead. I did so in my parser and then checked with AQTime wha

5条回答
  •  心在旅途
    2020-12-05 11:52

    A free sampling profiler for Delphi can be found there:

    https://forums.codegear.com/thread.jspa?messageID=18506

    Apart from the issue of incorrect time measurement of instrumenting profilers, it should be noted that which is faster will also depend on how predictable the "case" branches are. If the tests in the "case" have all a similar probability of being encountered, performance of "case" can end up lower than that of CharInSet.

提交回复
热议问题