Re: Newbie
From: William Park (opengeometry@yahoo.ca)
Date: 04/24/03
- Next message: Stephane CHAZELAS: "Re: Newbie"
- Previous message: Savio Sena: "Re: /bin/ksh not found"
- In reply to: Stephane CHAZELAS: "Re: Newbie"
- Next in thread: Stephane CHAZELAS: "[OT] Re: Newbie"
- Reply: Stephane CHAZELAS: "[OT] Re: Newbie"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: William Park <opengeometry@yahoo.ca> Date: 24 Apr 2003 13:46:06 GMT
Stephane CHAZELAS <stephane_chazelas@yahoo.fr> wrote:
> William Park wrote:
> [...]
>> - read a line
>> - break the line into one character per line in a temporary file
>> - grep, sort, uniq -c
>
> So, for each line (there may be billions).
>
> if line is length n.
>
> - Do n+1 read system calls (eventually more and behave badly if
> line ends with \)
> - fork, exec fold(1) (so do many more read/mmap... system calls,
> so the point above is negligible). Fortunately after the first
> line, fold, sort, grep, uniq code will be in memory, so it
> will only waste CPU time and memory bus bandwidth.
> - create a temporary file (not necessary and source of dozens of
> problems, not to speak of inefficiency).
> - sort the input while it's not necessary (if lines are long, it
> will use memory and eventually create temporary files), all
> you need is 26 integers to store the result.
> - 3 forks, 3 execs, two pipes for grep|sort|uniq.
> - And what will you use to reformat and display the result? awk?
> - How will the temporay file be created? How will it be removed?
> What if CTRL-C is hit, will it leave the file?
>
> Were you really serious?
Yes, Stephane. The solution will be shorter, faster, and cheaper than
the time you devoted for the above analysis.
-- William Park, Open Geometry Consulting, <opengeometry@yahoo.ca> Linux solution for data management and processing.
- Next message: Stephane CHAZELAS: "Re: Newbie"
- Previous message: Savio Sena: "Re: /bin/ksh not found"
- In reply to: Stephane CHAZELAS: "Re: Newbie"
- Next in thread: Stephane CHAZELAS: "[OT] Re: Newbie"
- Reply: Stephane CHAZELAS: "[OT] Re: Newbie"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|