I decided to tinker with this idea a bit more, to get a better impression of how much slower using cut and awk really is. I made each of the following functions iterate 100 times. I am pretty sure some of you will be shocked by the speed difference between cut and awk, versus the shell native string splitting.
Showing posts with label cut. Show all posts
Showing posts with label cut. Show all posts
Tuesday, January 12, 2010
Optimizing your shell scripts
A few days ago I came across a couple of posts, by Brock Noland, (blog site is dead now) about splitting strings natively with the shell. You can find them here here (Internet archive) and here here. Basically, the writer demonstrated that using shell builtins and variables is much more desirable than using outside programs, such as cut and awk for the same purpose. The reason for this is due to speed. Every time you make a call to an outside program with the shell, you fork a new process, and that takes time.
I decided to tinker with this idea a bit more, to get a better impression of how much slower using cut and awk really is. I made each of the following functions iterate 100 times. I am pretty sure some of you will be shocked by the speed difference between cut and awk, versus the shell native string splitting.
I decided to tinker with this idea a bit more, to get a better impression of how much slower using cut and awk really is. I made each of the following functions iterate 100 times. I am pretty sure some of you will be shocked by the speed difference between cut and awk, versus the shell native string splitting.
Subscribe to:
Posts (Atom)