HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

<=, >=, >, and <

11-07-2007, 11:47 PM#1
MrApples
Out of '<=, >=, >, and <', which one is the fastest?
11-07-2007, 11:55 PM#2
grim001
lol.
11-07-2007, 11:59 PM#3
TEC_Ghost
You're kidding right?

Please god say you're making a funny?
11-08-2007, 12:15 AM#4
cohadar
<= is the fastest
11-08-2007, 12:17 AM#5
PipeDream
Laugh until you remember this is Blizzard we're talking about.

1.
JASS is compiled down to a bytecode. In grimoire/src/opcode.h you'll find:
Code:
OP_EQUALS=0x1A,OP_LESSEREQUAL=0x1C,OP_GREATEREQUAL=0x1D,OP_LESSER=0x1E,OP_GREATER=0x1F
So, first psychotic thing, <= and >= use different opcodes! Yes, operations which should be identical! Different operations! Now the implementations are almost identical, but there is a 1 bit difference, and with a CPU as complex and weird with branch prediction as the x86, they *could* have slightly different speeds. But really, no.

2.
Now, while JASS the language is statically typed, the VM was implemented with dynamic typing. This doesn't matter for <= vs <, but for <= vs == you can imagine it could, as there is a new choice to dick with, the handle.

3. <= vs < is essentially identical. For each type, the same comparison instruction is used with a different interpretation of the resulting flags. Oddly, for reals, they use the floating point instructions of the machines rather than their emulation library. One nice thing about this is that the semantics of not > should be identical to <=; note that not == and != are different!

4. You have the tools to answer questions of speed for yourself, so go test, and tell us if there are any surprises.
11-08-2007, 12:20 AM#6
cohadar
I just got tired, forget about it..
11-08-2007, 12:30 AM#7
PipeDream
No, and I don't necessarily agree that for floating point numbers >= as the complement to < is the only reasonable definition.
11-08-2007, 02:33 AM#8
Salbrismind
Who the hell cares anyway? Its not like you can choose between them. Either your code needs one or another I can't imagine a time when I thought I could use many different ones. Even if there is a case it is likely that the shortest in code length would be obvious.
11-08-2007, 03:17 AM#9
MrApples
Well I sort of want to understand how it works better, so yes, I was serious. Being told that boolean checks used the same power as string checks lead up to this.

Not familiar enough with Grimoire to use it, I have it yea, but don't use it. You made that right Pipe? Maybe pitzer...