Max/MSP Test 02 :: (message) vs [trigger]/[prepend]
There’s been a lot of hearsay about whether or not the (message) object is efficient or not – why not just test it?
The test works like my previous execution tests, slamming 100,000 bangs/values as quickly as possible, and timing how long that takes to run through the given test.
This is a simple comparison in a very specific use case: creating a known value (and pair of values) using only the (message) and [trigger]/[prepend] objects.
Let’s find out which method is faster!
|METHOD||EXECUTION TIME (ms)|
|(single value) Message||16|
|(single value) Trigger||4|
|(two values) Message||19|
|(two values) Trigger/Prepend||9|
|(use case) Message||31|
|(use case) Trigger/Prepend||20|
I suggest downloading the patch and having it open while you read this section. Alternatively, open the image of the test above to follow as you go.
Click on the tabs below to display each category of the test…
Here the test is simple: jam 100,00 bangs into a (message) object with a single value (or “atom”), time it, then compare it to using a [trigger] (or [t]) object to get the same result.
This is a very important thing to remember – we’re only dealing with a single “atom”. In a future test I’ll demonstrate where the (message) object shines.
This is a very common method of generating a particular value. Within a message object any atom (or array of atoms) can be stored and output at a later time. In this case, we’re just testing it with a “1” stored in it.
Here we have it. The baseline test results of outputting a single atom from a (message) object verses from a [trigger] object.
The bottom line is, if you’re outputting a single known value, a lot, use a [trigger] instead of a message. It’s 4 times faster.
Now we deal with outputting two values in an array of atoms. The [trigger] object is limited in this, and can only output single atoms in sequence. In order to generate an array we’ll add a [prepend] object which simply adds an atom to the start of its input message.
Here things slow down only a touch. We’ve added 3ms from the previous test where we deal with a single atom.
Generating a two atom array using a [trigger] and [prepend] object inline slows down this test, halving its original speed. However, double the speed of the (message) still means a lot.
Here I put together a simple use case for the previous test.
In the end this test simply demonstrates that the speed difference between the two methods doesn’t change when connecting their outlets to an additional process, in this case a dictionary call.