SLUG Mailing List Archives
Re: [SLUG] Tuesday afternoon shell command optimisation party!
- To: Matthew Hannigan <mlh@xxxxxxxxxx>
- Subject: Re: [SLUG] Tuesday afternoon shell command optimisation party!
- From: Ian Wienand <ianw@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 19 Dec 2007 15:23:07 +1100
- Cc: slug@xxxxxxxxxxx
- User-agent: Mutt/1.5.13 (2006-08-11)
On Wed, Dec 19, 2007 at 02:51:34PM +1100, Matthew Hannigan wrote:
> Here's one in lex; ripped off from the flex info page.
> I'd be interested in its performance compared to straight C.
> No doubt worse, just curious how much worse.
Similar to the Python version
ianw@lime:/tmp$ /usr/bin/time ./count < ./randomcommas
# of commas = 1287100
2.57user 0.02system 0:02.60elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+138minor)pagefaults 0swaps
I'm not even going to guess at what that version is actually doing! A
quick look says this one is CPU bound, compared to Python which is
% Cycles lost due to GR/load dependency stalls (lower is better): 0.31
% Cycles lost due to GR/load dependency stalls (lower is better): 46.25
The Python spends a lot of time sitting around waiting for data to
come from the cache/memory (load dependency stalls). The Lex version
doesn't so the extra time can be attributed to CPU work.