Page 1 of 1

Integer/long swaps: shaving off a few cycles

Posted: Mon Jan 28, 2008 1:57 pm
by dell_jockey
Deleted, see posts below....

Posted: Mon Jan 28, 2008 2:06 pm
by Trond
1. Don't do speed testing with the debugger on.
2. A normal "Swap a, b" is twice as fast as your XOR swap.

Posted: Mon Jan 28, 2008 2:15 pm
by dell_jockey
Trond wrote:1. Don't do speed testing with the debugger on.
2. A normal "Swap a, b" is twice as fast as your XOR swap.
1: not even to compare the relative merit of two methods? I know the durations measured will not be correct by a large margin, but surely that will be true for both methods tested?

2: I stand corrected here, I didn't even know PB had a swap built-in :oops: Thanks for pointing this out! I had downloaded a bit of code that had a swap macro included and assumed that PB doesn't have one. This set off my thought train. Should have checked the manual first.... So, without much ado, I deleted the post above....

Posted: Mon Jan 28, 2008 2:18 pm
by Trond
dell_jockey wrote:
Trond wrote:1. Don't do speed testing with the debugger on.
2. A normal "Swap a, b" is twice as fast as your XOR swap.
1: not even to compare the relative merit of two methods?
No. Because native commands aren't slowed down by the same magnitude as your own with the debugger on.