lrose
April 22, 2025, 11:52am
7
This is still a bit too broad.
You use a transform to transform the value before it is used elsewhere.
You use a change script to react to a value changing.
Any time that you're using a script you have to pay the performance price for firing up the interpreter. That doesn't mean don't use them, it's just a fact of life. However, for transforms, if you can accomplish the task via another method (say an expression) then you should take that route.
Here are a couple of posts on the matter:
This is an interesting question, because it's true that most of IU is geared toward beginner level/just getting started content, and we don't really have much that targets the intermediate-to-advanced skill level.
I'll start with some general wisdom:
If you don't have to script it, don't.
If you do have to script it, prefer to write it in a project script rather than a 'magic pushbutton'.
Don't repeat yourself , but also write everything twice, because bad abstractions can hurt more, and chanc…
In this example, #3 is the most performant, though it could be argued that the performance gain in this instance would be negligible. Anytime you add an additional processing step you add latency.
In general for the best performance I follow these guidelines:
If you can achieve what you want with a binding, use a binding.
Always use the binding type that is the most direct. (e.g. if all you need is a binding to a property use a property binding, not an expression binding.)
Given the choice b…
Collected some overhead stats. Added a sixth binding for comparison, and made them all trigger from a common reference. The new expression transform looks like this:
nanoTime() - {value}
It is notably faster than the other transforms.
To make the recorder() run smoothly, I made a trigger timestamp with now({this.custom.pace}) and set pace to 200. Then I modified the transforms' first stages to look like this:
asList(
{this.custom.trigger},
nanoTime()
)[1]
The non-transform tests of run…
3 Likes