home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!msdrl!ball
- From: ball@msdrl.com (Richard Ball)
- Subject: too slowwwww....
- Message-ID: <1992Jul24.195547.18759@msdrl.com>
- Organization: Merck Research Laboratories
- Date: Fri, 24 Jul 92 19:55:47 GMT
- Lines: 41
-
- 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 few here with interests in speed and scalability I
- would like to solicit suggestions for improvement.
- The input file looks like this
- 5.939 u 6.001 u mt
- 4.002 u 3.221 u lt
- [ with lots more lt type lines]
- s
- 7.845 u 1.669 u mt
- [etc., etc.]
- for about 9 or 10 K lines. What I want to do is multiply each of the numbers
- by a factor, strip out the u characters, strip off the t characters and convert
- the s to S, ie.
- 427.6 432.1 m
- 288.1 231.9 l
- [etc.]
- S
- [and so on]
-
- 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
-
-