[H-GEN] ASCII Characters

David Jericho davidj at pisoftware.com
Mon Oct 27 20:15:08 EST 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

Mark Suter wrote:
> So just write it that way!
>     < input strings > output

I used to do that, but once bitten, twice shy.

If viewing a script quickly, and I'm looking for a particular event, 
it's easier to spot "cat | " as a pattern rather than "< filename". 
Occasionally people in their moments of brilliance will name a filename 
in a way that makes it look similar to an executable.

I was discussing this with Paul getting coffee this morning, and I have 
no objection to the above methods. But I explained that with systems 
administrator, where you do have the ability to take out a company's 
critical data with a hit of a button, consistency is the name of the 
game. With cat, there is no doubt at all as to what is going on.

If I _always_ use "cat filename |", I can change my scripts to "lynx 
-source url |", or "nc -l -p 5000 |", to "dd if=/dev/nst0 |", and it'll 
all work the same way.

There was the issue of performance brought up, so I thought I'd play 
with dd, cat, and straight redirection. I created a 1GB file from 
/dev/zero. All using default options, no special block sizes. I used 
mbuffer to attain basic speed states, as well as using time.

On a Pentium 4 at 2.4GHz, with 1GB of ram, lightly loaded with desktop 
tasks, the results were pretty much as follows.

Commands run were
Test 1) time bash -c 'cat bigfile | mbuffer > /dev/null'
Test 2) time bash -c 'dd if=bigfile | mbuffer > /dev/null'
Test 3) time bash -c 'mbuffer < bigfile > /dev/null'[1]

Throughput was consistent between all three tests, being limited by disk 
IO of around 47Mbyte/s.

Results:-
Test 1)
	User time average: 0.78 seconds
	System time average: 3.3 seconds

Test 2)
	User time average: 4.0 seconds
	System time average: 6.68

Test 3)
	User time average: 0.450 seconds
	System time average: 2.55 seconds

One interesting observation is that all tasks took approximately 20 - 22 
seconds to complete. The shell redirection had the fastest total time 19 
seconds, and the slowest total time of 35 seconds. I would have to run 
some profiling libraries to get a better indication of real load.

I know quite well these are hardly accurate tests for a whole variety of 
reasons, and without using profiling libraries I'm not going to get 
anything overly meaningful. How they are meaningful for me is that in 
the end, the task wasn't much quicker either way. The disparty between 
input devices, and the processor bus was great enough that in all cases, 
there was plenty of left over time for other tasks.

[1] Notice that "time bash -c '< bigfile mbuffer > bigfile' " appears 
ambigious? Remove the "bash -c" bit, and you're left with "time < 
bigfile mbuffer > bigfile". What's taking the input, time, or mbuffer?[2]
[2] Rhetorical, but I'm sure you get the drift.

-- 
David Jericho
Systems Administrator, Plugged In Software


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list