NeoCool's Realm

#!/bin/bash


Readable scripts vs. One liners


Recently, I had this file which contains some {start,end} times and I wanted to calculate the total amount of time. This script contains two methods to process it: one long and slow version which is perfectly readable and a one liner which is much faster, but a bit harder to understand. You should always try to come up with a short and fast solution for your scripts, because you just write them once, but run them often. Long scripts may be more readable, but with a few comments the one liner solution is always better.
Sample output:

Readable version:

134

real    0m0.077s
user    0m0.015s
sys     0m0.060s


One liner:

134

real    0m0.008s
user    0m0.000s
sys     0m0.005s


Logo. Created by Boris Buegling. 100 % handcoded HTML. Created with ViM.