http://qs1969.pair.com?node_id=213095


in reply to Re: Efficient run determination.
in thread Efficient run determination.

Well, I ran some benchmarks myself, basically because I wanted validation :) I like to think I'm not biased but that's probably untrue :)

For 1000 iterations over the given test string, the time to complete is given in seconds. Some of the solutions provided were modified slightly so that they were contained in a function, and returned an AoA containing the results.

PhiRatE 1:  0.042767s
Dingus 2:   0.083538s
Dingus 1:   0.106047s
TommyW 1:   0.117478s
Enlil 2:    0.138005s
Robartes 1: 0.217086s
Rasta 1:    0.273936s

The Inline C function I proposed is nearly twice as fast as the nearest all-perl competitor (Dingus' 2nd attempt). I must admit its not as much of an advantage as I had expected, but still clear. A run of 10000 each revealed almost exactly the same ratios.

Please note that no attempt to validate the correctness of any of the entries was made.

For further interest I did a test with a considerably longer string (1920 chars):

PhiRatE:     2.238917s
Dingus 1:    5.350828s
Dingus 2:    5.474964s
Enlil 2:     9.461141s
TommyW 1:    8.870724s
Robartes 1: 10.239816s
Rasta 1:    19.996283s

The inline method is even further ahead in this test. Interestingly Dingus 2, which had previously performed second-best, dropped to 3rd. Possibly due to the different nature of the data or some non O(1) operations within the calls made. Others held up variously against the increased length. The operation was fairly memory intensive but I ran all the competitors in various orders to ensure that it wasn't affecting anything.