From what I can see, the delay does not stem from calling the plugin itself.
Let's look at the last tests in your sequence:
Test one(print to log directly, wait for plugin execution)
before to when: 1.4976ms
when to after: 1.5104ms
Total execution time: 3.008ms
Test two(use an intermediate variable, wait for plugin execution)
before to when: 4.5056ms
when to after: 3.008ms
Total execution time: 7.5136ms
Test three(print to log directly, don't wait for plugin execution)
before to when: 23.0016ms
when to after: -0.4992ms (I'm guessing the plugin write happened after the black write to log action)
Total execution time: 23.5008ms
Test four(use an intermediate variable, don't wait for plugin execution)
before to when: 16ms
when to after: 3.008ms
Total execution time: 19.008ms
While it is strange that apparently not waiting for the plugin means execution takes longer(
), no execution takes longer than a few tens of milliseconds.
I'm not sure where the delay you're experiencing occurs, but it doesn't appear to be when calling the plugin.
Have you tried making a single call to one of the HCS plugins and checking how long it takes for the return?