“Set Variable" vs “Insert Calculated Result"

WARNING: This post is a bit rough around the edges (and might see some noted edits).
Posting it now "as is" based on a back channel suggestion that just came in....

On a previous post it was stated that (under the hood) the “Set Variable" script step sets an [immutable variable] while the “Insert Calculated Result targeting a $var (available as of FM 16 and up) script step sets an [mutable variable] and therefore, the "insert calculated result” script step is more performant (in some cases) when a $var is being written to more than once, for example in a loop.

It seems as there are a number of use cases to be tested:

  • Override a variable with text, replacing the pre-exiting value
  • Append text to the end of a variable
  • Insert text into a a variable (block of text) using JSONSetElement
  • Declaring a variable just once

Here is some background discussion on the first point:
Use "Insert Calculated Result" to concatenate strings! <= Groundbreaking Performance Leap!
https://community.claris.com/en/s/question/0D50H00006dsly8SAA
Posted by @mrwatson-de (Claris Community (English))

Lets dig for more gold!

What are the comparative advantage of “Set Variable” vs. “Insert Calculated Result” targeting a $var (or $$var)

FileMaker 16 and above is required to target a $var or $$var
https://fmhelp.filemaker.com/help/16/fmp/en/index.html#page/FMP_Help/new-features.html

Insert Calculated Result can be faster when a $var is being written to more than once, for example in a loop.

The user interface for “Insert Calculated Result” requires 1 less click to access the calculation engine

There seems to be a gotcha if you run the Insert Calculated Result while your curser is in a field
https://community.claris.com/en/s/question/0D50H00007RPXYDSA5/insert-calculated-result-strangeness

Others?

My two cents...

I've not seen any instances where using ICR is faster in this scenario

I've seen huge improvements in performance using ICR when working with large blocks of text in variables, regardless of whether appending text or using JSON Functions, especially in loops. Don't have any metrics to hand though...

I would not expect to see any improvement in performance using ICR.