Next | Making Programs Faster | 7 |
@sorted_names = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [ $_, -M $_ ] } readdir D;
This is more complicated and more work than the original code:
sort { -M $b <=> -M $a } readdir D;
Is it really faster?
To find out, we run both versions on the same data
We measure the time taken by each one
This is called a benchmark
Next | Copyright © 2003 M. J. Dominus |