home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!msdrl!ball
- From: ball@msdrl.com (Richard Ball)
- Subject: too slowwww.....
- Message-ID: <1992Jul28.130015.23389@msdrl.com>
- Organization: Merck Research Laboratories
- Date: Tue, 28 Jul 92 13:00:15 GMT
- Lines: 38
-
- (My apologies if this is a repost (someone please let me know if it is) but
- news was a liile flakey and I'm not sure if this got out. The following is
- the gist of my question)
-
- After learning a little perl I thought I would apply it to a task I had in
- reformatting a postscript file. My filter, not surprisingly I guess, runs very
- slowly and since there are a few here with interests in speed and scalability I
- would like to solicit suggestions for improvement. I am mchanging a file from
- this to this
- 5.939 u 6.001 u mt 427.6 432.1 m
- 4.002 u 3.221 u lt 288.1 231.9 l
- [ with lots more lt type lines] [etc]
- s S
- 7.845 u 1.669 u mt 564.8 120.2 m
- [etc., etc.] [etc., etc.]
-
- file size is about 9 or 10 K lines.
-
- The guts of my script are:
- while (<STDIN>){
- if (/^s/) {print "S\n"; next;}
- tr/u//d;
- ($x, $y, $mode) = split(' ');
- chop($mode);
- $x = $x * 72;
- $y = $y * 72;
- printf "%6.1f %6.1f $s\n", $x, $y, $mode;
- }
-
- But this takes almost a minute on an 8K line file! From some testing its clear
- the split and the printf are the worst time hogs. I want the effects of the
- printf though so I only get 1 decimal place on the output.
- Anyone got any tricks that will get the time down?
-
- R.G. Ball | phone: 908-594-5341
- Merck Research Laboratories | FAX: 908-594-6645
- PO Box 2000, MD:RY80N-18A | email: ball@msdrl.com
- Rahway, NJ 07065 USA | or ...!uunet!msdrl!ball
-