Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Language speed [was Re: Good TK book]
This version seems to need some finishing touch:
i have not looked in details, but found the following strangenesses:
- thread benchmark: LUA seems to create 1000 threads, not 3000
as required
- thread benchmark: Java result failed, but it is counted
- regex for tcl says: "No program", clicking on it shows a
tcl program
- ackermann runs out of stack. It should be possible to fix it
with "interp recursionlimit ..."; the following version
should be somewhat faster than the version with expr.

-gustaf
PS: Google news did not let me follow up, so i had to remove the "re:"
from the subject line.

 ========================================
===========================
interp recursionlimit {} 100000
set NUM [expr {[lindex $argv 0] < 0 ? 1 : [lindex $argv 0]}]

proc ack {m n} {
if {$m == 0} {        incr n
} elseif {$n == 0} {  ack [incr m -1] 1
} else {   	          ack [expr {$m - 1}] [ack $m [incr n -1]]
}
}

puts "Ack(3,$NUM): [ack 3 $NUM]"

Report this thread to moderator Post Follow-up to this message
Old Post
Gustaf Neumann
12-30-04 01:58 AM


Re: Language speed [was Re: Good TK book]
"Gustaf Neumann" <neumann@wu-wien.ac.at> wrote
>   - ackermann runs out of stack. It should be possible
> to fix it with "interp recursionlimit ..."; the following
> version should be somewhat faster than the version
> with expr.

Gustaf,

I just submitted a new ackermann.tcl setting recursion limit.  I tried
replacing [expr {$m-1}] and friends with [incr m -1].  Small positive
difference for [incr n], and no difference, or perhaps even a penalty
for [incr m -1].

Bob
--
Bob Techentin                   techentin.robert@NOSPAMmayo.edu
Mayo Foundation                                 (507) 538-5495
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/




Report this thread to moderator Post Follow-up to this message
Old Post
Bob Techentin
12-30-04 01:58 AM


Re: Language speed [was Re: Good TK book]
A small additional gain (1-10% depending on NUM) can be won optimizing
the proc ack like

interp recursionlimit {} 100000
set NUM [expr {[lindex $argv 0] < 0 ? 1 : [lindex $argv 0]}]

proc ack {m n} {
if {$m} {
if {$n} { return [ack [expr {$m -1}] [ack $m [expr {$n -1}]]]
} else  { return [ack [expr {$m -1}] 1]                       }
} else      { return [incr n]                                     }
}

puts "Ack(3,$NUM): [ack 3 $NUM]"


Yes [incr m -1] has a penalty and is slower than [expr {$m-1}].
But as i remember expr should be slower, or is this past?


Bob Techentin wrote:
> "Gustaf Neumann" <neumann@wu-wien.ac.at> wrote
> 
>
>
> Gustaf,
>
> I just submitted a new ackermann.tcl setting recursion limit.  I tried
> replacing [expr {$m-1}] and friends with [incr m -1].  Small positive
> difference for [incr n], and no difference, or perhaps even a penalty
> for [incr m -1].
>
> Bob

Report this thread to moderator Post Follow-up to this message
Old Post
Stefan Finzel
12-30-04 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:54 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.