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 builtins. Show all posts
Showing posts with label builtins. 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.
Monday, December 28, 2009
Using pushd, popd and dirs
Since I have a bit of time on my hands, I thought I might share a trick or two. Well, not really 'tricks,' but good information to know. I will cover the shell builtins, pushd, popd, and dirs for bash and zsh. Additionally, I will demonstrate how to use some shell aliases, in order to make the use of these handy builtins even more convenient, and time saving.
Subscribe to:
Posts (Atom)