[mdlug] UNIX tips: Learn 10 good UNIX usage habits

Robert Meier list1c30fe42 at bellsouth.net
Tue Mar 11 08:37:00 EDT 2008


Robert,

Good experiment.
> [
> $ yes and | head -$COUNT > tmp/a/longfile.txt
> ]

> [
> COUNT             2          20M       200M
>                            
> real(cat)         0m0.005s  -0m1.383s  -0m20.297s
> real(inline)     -0m0.004s   0m2.142s   0m24.169s

> user(cat)         0m0.008s   0m1.344s  -0m12.769s
> user(inline)     -0m0.004s  -0m1.340s   0m13.549s

> sys(cat)          0m0.000s   0m0.108s   0m1.352s
> sys(inline)       0m0.000s  -0m0.036s  -0m0.576s
> ...
> laptop running Ubuntu 7.10 with dual 2GHz cpus and 1GB RAM ...
> ]

Duplicated on my Dell Latitude, SuSE-10.1, single PentiumIII 850MHz, 256M RAM.

for COUNT in 2 20000000 200000000
do
  yes and | head -$COUNT > /local/tmp/a/longfile.txt
  time -p cat /local/tmp/a/longfile.txt | grep -c and
  time -p grep -c and /local/tmp/a/longfile.txt
  time -p < /local/tmp/a/longfile.txt grep -c and
done
2
real 0.00
user 0.00
sys 0.00
2
real 0.00
user 0.00
sys 0.00
2
real 0.00
user 0.00
sys 0.00
20000000
real 7.39
user 6.58
sys 0.43
20000000
real 6.71
user 6.41
sys 0.21
20000000
real 7.17
user 6.47
sys 0.30
200000000
real 76.21
user 64.78
sys 4.78
200000000
real 72.08
user 64.75
sys 2.67
200000000
real 68.81
user 64.16
sys 2.66

COUNT             2          20M       200M
                           
real(cat)         0.00       7.39      76.21
real(inline)      0.00      -6.71      72.08
real(redirect)    0.00       7.17     -68.81

user(cat)         0.00       6.58      64.78
user(inline)      0.00      -6.41      64.75
user(redirect)    0.00       6.47     -64.16

sys(cat)          0.00       0.43       4.78
sys(inline)       0.00      -0.21       2.67
sys(redirect)     0.00       0.30      -2.66

Mileage varies,
but in these two experiments,
not by more than 10%(of real) real, 3%(of real) user, 3%(of real) sys

Reporting,
-- 
Bob

  "The liberties of our country are worth defending at all hazards. We have
   received them from our worthy ancestors; they purchased them for us with
   toil, treasure and blood. It will bring an everlasting infamy on the
   present generation, enlightened as it is, if we should suffer them to be
   wrested from us...or be cheated out of them by the artifices of false and
   designing men."
	     -- Samuel Adams, 1771.




More information about the mdlug mailing list