Difficult one

Started by Jeff, May 03, 2007, 02:04:00 PM

Previous topic - Next topic

Jeff

#15
I like recursion because I think it is an elegant, DRY solution.  However, I do realize it's often not the most efficient way to do things.



In comparing language speeds, another thing to think about is that newLisp always gets a head start due to its interpreter size.  On just a few hundred iterations, Python will never come close to newLisp because the actions take less time than loading its interpreter.



If the program runs for several seconds or more, though, then you can start to marginalize the load time.  Python seems to run pretty well once it is loaded.



The problem I'm trying to solve is that newLisp should be killing Python in every aspect of this program.  When testing feature for feature, newLisp beats the pants off of Python for regexp, list assembly, et al.  Therefore, it must be the programmer, not the language, and I'm trying to figure out where I could be writing better code.



Edit:  After thinking about the last few posts, I tried testing the speed of (dolist (nm nm-list) (parse-name nm)), and it was about 15% faster.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

cormullion

#16
I haven't got anything useful to say (above my head, most of it) but - just for interest - what speed differences are you expecting and noticing?



(Recently I did a blog entry trying to match a 75ms Perl script, starting off with a newLISP version which started out taking 1.2 seconds. Obviously a factor of 10 is worth looking into...!  Not that I'm a speed freak - just that discrepancies are intriguing.)

Lutz

#17
here is another suggestion for Jeff to speedup the name parser code:


> (time (format "%s %s %s" "hi" "ho" "hum") 1000000)
4818
> (time (append  "hi" " "  "ho" " " "hum") 1000000)
1723
>

when using 'format' for simple string appending with filling in text in between, 'append' can be a lot faster.



This is for the '(format "%s %s %s" $3 $1 $2)' pieces in the normalize function.



Lutz



ps: timings on MacMini G4

rickyboy

#18
Quote from: "Lutz"This is for the '(format "%s %s %s" $3 $1 $2)' pieces in the normalize function.

I wonder if, also, the formats in format-name should be switched to appends or anything else faster.  Jeff said his speed discrepancy was noted when running format-name under map.  Just a thought.
(λx. x x) (λx. x x)

Jeff

#19
Using append, I've gotten execution over 7,896 names down to 1,075 ms, excluding interpreter load time.  In python, the same number of names is around 975 ms without counting the interpreter.  If I change from iteration to list assignment (using map or a list comprehension), I add only about 50-100 ms to either.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code