combine VS sprintf?

Nov 27, 2012 at 1:59pm

combine VS sprintf?

I’ve read somewhere on this forum that sprintf takes MORE resources because… I forgot why.
Is it more economical to use combine where is feasible?

#65388
Nov 27, 2012 at 3:10pm

Hi,

No. In case you have thousands of messages to format, perhaps ; but profile your patch first before any optimizations. My 2 cents.

– Pasted Max Patch, click to expand. –
#235603
Nov 27, 2012 at 7:26pm

What do you mean by “profile your patch”?

I never knew that objects, thanks for pointing me to it.

#235604
Nov 27, 2012 at 9:50pm

The combine help file mentions: “Please note that for every single unique time that is output by combine a new symbol will be added to Max’s symbol table consuming an ever growing amount of Max’s resources.”

In this behavior it is identical to sprintf. Was this what you are referring to? It means that in some cases it is better to avoid the use of sprintf or combine altogether.

#235605
Nov 28, 2012 at 7:04am

Hi,

- By “profile your patch” i refer to various techniques to find bottlenecks. You can use an application like “Shark”, if you are familiar with software development, or just mute parts of your patch and use a CPU monitoring. That is a good habit to prefer lightweight objects (you can use [cpuclock] as above to compare them) but do not lose your time in tiny optimizations that will not impact the global cost.

- Instead of [sprintf] or [combine] can’t you do the job with [append] and [prepend] ?

#235606
Nov 28, 2012 at 2:03pm

@jvkr: yeah, that’s what I was thinking about exactly.

@nicolas danet: Not exactly, because I’m dynamically accessing and writing directly to pattrstorage, so I need the form “patcher[x1]::sub patch[x2]::object
I’m using join for actual
to avoid having too many unique ID’s for combine/sprintf objects.

I’ll look into Shark as well, already using cpuclock.

Thanks a bunch.

#235607

You must be logged in to reply to this topic.