Prepending

Feb 3, 2011 at 8:44pm

Prepending

A very elementary kind of question I’m sure, but I’m wondering if there is any computational difference or whether one method might be preferred over the other in the case of prepending with the prepend object or with a message object.

– Pasted Max Patch, click to expand. –
#54552
Feb 3, 2011 at 8:49pm

i cant look at the patch but i can guess the situation.

using a messagebox is definetly slower because of the graphics update
which probably need 10 times more CPU to pass “hello” than all other
objects together.

thats true for everything with graphics. so as soon as you are experienced
enough to know things like gate, bang, messages by heart you should
stop using button, flonum, messagebox, grapic gates and this stuff as
they only make your patch slower.

-110

#196477
Feb 4, 2011 at 7:08am

Hello stringtapper,

a quick benchmark seems to show that [prepend] is fastest but no significant way, at least in max 5.1.7 ; It is surprising, i always believed that the gap between message box and [prepend] was bigger.

– Pasted Max Patch, click to expand. –
#196478
Feb 4, 2011 at 2:54pm

vanille: what about sprintf? of course it wont work for lists.

#196479
Feb 4, 2011 at 3:34pm

Hello Roman,

IMHO : [sprintf] isn’t very efficient (really ugly) …

anyway i’m not sure this kind of benchmark are really interesting except if you use thousand of the same object, but in this case maybe it’s time to change/organize your patch (or to learn C) ;-)

but for fun and prettyProfessionaLikePatchingStyle [prepend] is the best !

#196480
Feb 5, 2011 at 4:21am

Thanks for the comments. I see it’s probably as trivial as I thought it might be when it comes to small patches.

#196481
Nov 8, 2011 at 2:57am

There’s a really cool tool called ‘pedant’ in the toolbox area, It compares the execution speed of 2 patchers (and can do N executions and calculate the average execution time).

I use it all the time and had a few surprises on what is efficient code and what isn’t.

#196482

You must be logged in to reply to this topic.