This separate patch to simplify the print_kth() function
by removing the comparison from it, is simple and
has a significant perf advantage. Tests pass so I'll apply.

I'll adjust the commit log to summarise the perf change,
but I notice the change isn't as great as yours on my sandybridge i3 system.
Benchmark results for both the rebased memory rework and
the simple print_kth() optimization attached.

thanks!
Pádraig.
### small ranges
$ yes abcdfeg | head -n1MB > big-file
$ for c in orig split mem; do src/cut-$c 2>/dev/null; time src/cut-$c -b1,3 
big-file > /dev/null; done

real    0m0.083s
user    0m0.080s
sys     0m0.003s

real    0m0.069s
user    0m0.061s
sys     0m0.007s

real    0m0.068s
user    0m0.066s
sys     0m0.001s


### bigger ranges
$ yes $(yes a | head -n100000 | tr -d '\n') | head -n10000 > big-lines
$ for c in orig split mem; do src/cut-$c 2>/dev/null; time src/cut-$c 
-b50-100,101-105,9999 big-lines > /dev/null; done

real    0m9.951s
user    0m9.065s
sys     0m0.810s

real    0m8.542s
user    0m7.586s
sys     0m0.876s

real    0m10.149s
user    0m8.875s
sys     0m1.145s

### fields
yes "a:b:c:d:e" | head -n1MB > fields
$ for c in orig split mem; do src/cut-$c 2>/dev/null; time src/cut-$c -f2,3 -d: 
fields > /dev/null; done

real    0m0.172s
user    0m0.167s
sys     0m0.004s

real    0m0.149s
user    0m0.146s
sys     0m0.003s

real    0m0.145s
user    0m0.141s
sys     0m0.004s

### --output-delimiter
$ for c in orig split mem; do src/cut-$c 2>/dev/null; time src/cut-$c -f2,3 -d: 
--output-d=' ' fields > /dev/null; done

real    0m0.159s
user    0m0.153s
sys     0m0.005s

real    0m0.144s
user    0m0.141s
sys     0m0.003s

real    0m0.137s
user    0m0.133s
sys     0m0.004s

Reply via email to