in reply to notequal very slow

You're either wrong, using something tricky that doesn't show in this example (like lots of symbolic references or tie()d arrays) or the rest of the code is so simple it doesn't do anything useful and you're worrying for no reason at all.

IOW: show more of the code and include the way you've measured the speed of various parts of it.

update: the only thing that I can think off off-hand is that you've got enormous strings of equal length that are identical except for the end. But I'm pretty sure that that is not it.

Replies are listed 'Best First'.
Re^2: notequal very slow
by Anonymous Monk on Jan 15, 2008 at 19:28 UTC
    Hi Joost, Some of the string is indeed very long (almost 40 characters long) but most of the strings being compared is manageable length. Any magic I can do with perl that will make perl work faster in just that part of the code? :-)
      40 characters really isn't very long at all. Especially considering that comparing strings means you generally don't have to check the whole string:

      "b1234872938741279834712987398127398712983798123" eq "b2137298379812739812739871239871289379812739817" can be tested to be false after comparing only 2 characters, for example.

      In any case, I may be able to help you optimize things, but since I suspect the performance issue is somewhere else in your code you'll have to convince me that your analysis of the problem is correct. Showing that the slowness is in any way significant will help too - It's pointless to spend half an hour speeding up a program that won't take more than a minute of CPU time in its entire useful life :)

      40 characters is not very long. Thousands or millions might be considered long. Maybe the code inside the if{...} block (not the conditional itself) is the culprit? How are you measuring this?