9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Ralph Corderoy <ralph@inputplus.co.uk>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] text utility
Date: Wed, 30 Jul 2003 08:25:46 +0000	[thread overview]
Message-ID: <3828.3f264674.96335@blake.inputplus.co.uk> (raw)
In-Reply-To: <4e9a248eadf51083ac5d918159014eda@collyer.net>

Hi Geoff,

> One could use "pr -tn" instead of the little awk script, but the
> difference in speed really isn't that great.  Reading a cached ~2.5MB
> file of ~250K lines,
>
> cpu% time awk '{print NR, $0}' test >/dev/null
> 2.85u 0.13s 3.53r 	 awk {print NR, $0} test
> cpu% time pr -tn test >/dev/null
> 1.75u 0.13s 2.18r 	 pr -tn test

Fair enough.  Under AIX and Linux cat's a win.  Using yes(1) so awk's
little work to do:

    $ yes y | head -n 250000 | time awk '{print NR, $0}' >/dev/null
    real 1.13
    user 1.06
    sys 0.01
    $ yes y | head -n 250000 | time cat -n >/dev/null
    real 0.08
    user 0.05
    sys 0.00

I used it heavily when doing ad-hoc queries on files with millions of
lines.  But, like you say, if it's not present, it's no use.

Cheers,

--
Ralph Corderoy.      http://inputplus.co.uk/ralph/     http://troff.org/


      reply	other threads:[~2003-07-30  8:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-21 11:45 pac
2003-07-21 11:52 ` boyd, rounin
2003-07-22 14:09   ` rog
2003-07-22 14:35     ` boyd, rounin
2003-07-22 16:43       ` rog
2003-07-22 23:28     ` Geoff Collyer
2003-07-23 15:05       ` rog
2003-07-23 18:42         ` Dan Cross
2003-07-24  9:19           ` matt
2003-07-28  8:47       ` Ralph Corderoy
2003-07-28 21:58         ` Geoff Collyer
2003-07-30  8:25           ` Ralph Corderoy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3828.3f264674.96335@blake.inputplus.co.uk \
    --to=ralph@inputplus.co.uk \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).