VFP function to get the first line of a piece of text
I wrote three functions using each technique, then timed them on various inputs. I also timed the hybrid version. Times below are in microseconds on a 3GHz processor (obviously your mileage might vary)
| Input | mlines() | alines() | at() | hybrid() |
| Empty | 6.4 | 4.8 | 5.1 | 2.9 |
| One word | 6.5 | 5.7 | 5.1 | 3.0 |
| One line < 75 | 8.6 | 7.1 | 5.8 | 3.7 |
| One line > 75 | 10.6 | 8.9 | 5.7 | 10.3 |
| Two lines | 10.0 | 9.8 | 5.9 | 10.6 |
| Four lines | 9.0 | 12.9 | 5.8 | 10.4 |
| Multiline (400 chars) | 9.8 | 15.2 | 6.6 | 10.2 |
| Huge (5000 chars) | 19.7 | 120.9 | 13.5 | 19.3 |
The final function is around 40% slower than the hybrid function above, because of the extra parameters and checking code. It still beats any of the first three techniques on short input.
Source code to the four functions are on the next page.