Typing slowdown

I wrote a little Maple procedure. [It enumerates permutations of a bag/multiset by (as nearly as feasible) adjacent transpositions, in constant amortised time, and I was quite pleased with it     though that's neither here nor there.]

Nothing sophisticated: just using very basic features that might easily be ported to or from traditional mainstream languages, say Java or C++.

But it seemed to run rather slowly under Maple 9; so to speed things up a little, and to improve its portability, I decided to try using a feature I had previously ignored: specifying the types of function arguments, results, and local variables.

Now the compiler knows everything will be integer, 1-D array(integer), etc, and I can sit back and watch my test run     if not quite like the proverbial shirt off a shovel     at least slightly less like syrup off a spoon.

Or maybe not. With types specified, it doesn't actually run any faster.

It doesn't run at the same speed. Or even a bit more leisure(li)ly.

It actually takes 7x longer to run the same test.

That's right folks, execution is seven times slower with typing than without.

For crying out loud!      Fred Lunnon (spluttering apoplectically) [July 3rd 2008]


See the procedure in Bag Permutation Generator.


I tried to post the program under that thread on MaplePrimes, though I suspect it has been garbled: for some obscure reason, the previewer insists on displaying source plaintext. I have to say I find much of the other participants code displayed there unrecognisable as Maple! [Incidentally, there appears to be some machinery on this page for attaching comments. After filling in the box 3 times then getting "page not altered", I've given up trying to use it.] WFL


I'm not at my computer right now, so that will be posted as from a guest :) Recently there were 2 spam bot attacks on the wiki, so I added a captcha - some stupid questions that only humans can answer - at the top of the page - perhaps, they created a problem. The best way of posting a long (more than 2 lines ) code here is to start it with {{{#!maple on a separate line, then paste code, then end it with }}}, again on a separate line. -Alec

PS and you could safely delete all my comments after reading them - so that the page will be clean -Alec


Oh, I've just understood what you meant about the comment box - it is not for the comments on the page, it is for the comments about the change that was made - they don't show on the page - only on the RecentChanges page (and some changes on the page have to be made to save that.) The comments on the page can be made by using C-style comments - starting with /* and ending with */ - then the Comment link appears next to the Edit link at the top of the page, that toggles their visibility -Alec


Uh-huh --- I think I got all that. Re "captcha" --- I guessed the reason for that, but unfortunately my intellect remains evidently at spambot rather than human level, and the only way I can get past it is to keep pasting in my edits until the one question I can actually answer happens to show up ... Also noted your comment elsewhere about posting the program here. I'm concerned about the possibility that another user might make unauthorised alterations to it --- is there a simple way to lock it down? WFL


You have to be logged in for that. Then adding

#acl FredLunnon:read,write All:read

at the top of the page will make it writable only by you. Actually, it may be not such a good idea as it seems - because, for example, typos can not be corrected, or comments added. I don't do that on my pages. If somebody alters your code, then you can restore it later from RecentChanges page - everything is saved there, every change, and can be easily restored. For example, 2 bots that I talked about, destroyed the FrontPage completely, but I restored it just by clicking a button on the page that I viewed from RecentChanges page. -Alec


CategoryMaple

MapleGrumbles (last edited 2008-07-17 04:10:07 by AlecMihailovs)