Re: Brain-scratcher: New example of the delay
- Posted by CladStone Jun 15, 2009
- 1031 views
Sure, you could come up with a way to automate testing. I thought about it, but didn't get that far.
Regarding translation and/or binding: A capital suggestion; thank you. It took me a little while since I'd never done that before and didn't have a C compiler installed, but I've now tried both.
Binding:
I reproduced the problem using "bindw" to create a few .exe files. One runs fast with the value "x + 230" on line 4. Another runs slow with the value "x + 150". (I didn't take the time to track down the exact "cutoff" point I mentioned earlier - I just wanted to proof that something that ought not make a difference does.) The slow .exe is 2 bytes smaller, and has 29 other different bytes (at least 9 of these are merely shifted), whereas another fast one (using "x + 311") is the same size as the "x + 230" and only different by 4 bytes.
Translation:
The only difference I could produce in the generated C code was between "x + 2" (or higher) and "x + 1", but it only renamed 2 variables and changed a couple lines to make use of the unique number that "1" is, e.g. it used:
vs.
and
vs.
So it seems the problem was reproduced in binding, but not in translating. If you like, I can try to post those .exe files somewhere. I'm not really sure how to reverse engineer them and tell exactly what's going on, though I might try anyway.