Since a bit of time passed (a month) after I debated with Jim about the overall performance of linecut compared to an "equivalent" script in an interpreted language (perl, python, etc.), I wrote a small perl script [attached] and ran it and linecut on an older machine against a few-hundred lines textfile 'extracting' several slices of lines and have them print the slices to the terminal.
The outcome was that linecut performed significantly faster; as observed, the slower the machine is, the execution time difference increases (e.g., on a 400 Mhz CPU machine [specs attached] where the perl script and linecut were run against a ~250 lines textfile with 20 iterations, linecut performed a bit more than 3-times faster than the script). autotools and gnulib support has meanwhile been added, whereas proper documentation aside from manpage output generated by help2man is still lacking. Features/bugfixes that were added since last RFC include: * (internal): copy stdin to tempfile * (feature): range opts: + prefix (denoting advancement of lines) * (bugfix): abandon strlen() while buffering to tempfile I'm writing in the hope that, if still considered worthwhile, someone will take the time and point out some design flaws, subtle errors, and related bugs that weren't obvious to me or have been overlooked. <http://steven.refcnt.org/code/linecut/current/> 1. #!/usr/bin/perl use strict; use warnings; my @sets = ([1,2],[20,24],[50,100],[-30,-1]); my $file = $ARGV[0]; open(my $fh, '<', $file) or die "Can't open $file: $!\n"; my @lines = <$fh>; close($fh); foreach my $set (@sets) { my ($start, $end) = @$set; my $current = $start; while ($current <= $end) { print $lines[$current - 1]; $current++; } } 2. processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 5 model name : Pentium II (Deschutes) stepping : 1 cpu MHz : 400.913 cache size : 512 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 2 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr bogomips : 799.53 Steven Schubiger _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
