Run and Time: Performance of Tiddlywiki Scrript

78 views
Skip to first unread message

Mohammad

unread,
Mar 16, 2019, 11:20:37 AM3/16/19
to TiddlyWiki
Is there any code, macro, widget to calculate the elapsed time for any action in Tiddlywiki?

Is there a simple timer macro to see the elapsed time when another macro performs a task?

--Mohammad

Mohammad

unread,
Mar 16, 2019, 12:31:01 PM3/16/19
to TiddlyWiki
I tried something like this, with no success

\define run-n-time(macro, timerTid:"timerTid")
<$macrocall $name=timer timerTiddler=<<__timerTid__>> index=start/>
<$macrocall $name=<<__macro__>> />
<$macrocall $name=timer timerTiddler=<<__timerTid__>> index=stop/
>
\end

\define timer(timerTiddler:"timerTid", index:"start")
<$action-setfield
 $tiddler
=<<__timerTiddler__>>
 $index
=<<__index__>>
 $value
=<<now [UTC]YYYY0MM0DD0hh0mm0ssXXX>> />
\end

\define show-diff(timerTiddler)
<$set name=start value={{{ [<__timerTiddler__>getindex[start]split[]rest[8]join[]trim[]] }}}>
<$set name=stop value={{{ [<__timerTiddler__>getindex[stop]split[]rest[8]join[]trim[]] }}}>
<$list filter="[<stop>subtract<start>]" variable=elapsedTime>
<$text text=<<elapsedTime>> /
>
</$list>
</
$set>
</$set>
\end

Example like

<$button> Test 
<<run-n-time macro:"myMac" timerTid:"myTime">>
</$button>

Elapsed time:
<$macrocall $name="show-diff" timerTiddler="myTime" />



Or call timer directly before and after macro call!

This is what I use in Fortran, Matlab or Python!

--Mohammad

Jeremy Ruston

unread,
Mar 16, 2019, 12:31:52 PM3/16/19
to tiddl...@googlegroups.com
Hi Mohammad

Is there any code, macro, widget to calculate the elapsed time for any action in Tiddlywiki?

Is there a simple timer macro to see the elapsed time when another macro performs a task?

The core has built-in instrumentation for the refresh cycle. Find “Performance Instrumentation” on the “Settings” tab of control panel. You’ll need to reload the wiki before it takes effect.

With performance instrumentation switched on, you’ll see additional timing information in the browser developer console each time a refresh cycle is triggered. For example:

performance: mainRender: 327.83ms 
performance: +filter: 49.70ms 
performance: styleRefresh: 9.14ms 
performance: +filter: 2.46ms 
performance: mainRefresh: 68.10ms 
performance: +filter: 37.69ms 

The information above should be interpreted as follows:

“Initial rendering of the main page took 327ms (of which 50ms was filter evaluation). Refreshing the page stylesheet took 9ms (of which 2ms was filter evaluation). Refreshing the main page took 68ms (of which 38ms was filter evaluation)"

* mainRender is the time taken for the initial display of the page template
* styleRefresh is the time taken to refresh the page stylesheet
* mainRender is the time taken to refresh the main page template
* in each case, +filter denotes the time taken up with filter evaluation.

As an example, try switching between the sidebar tabs to compare how long they take to render.

Best wishes

Jeremy




--Mohammad

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/2456b5b8-8cfd-43d5-b6c4-28d76f649117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Mar 17, 2019, 2:16:53 AM3/17/19
to TiddlyWiki
Many thanks Jeremy,
 I was experimenting with Commander and noticed on 1000 tiddler above I have a performance loss
For example I created 1500 tiddlers.
Select all of them and add a prefix to their title like pre- It took around 6000 ms  in two steps!

By the way while I cannot check run and time for every single macro, but I can have a figure of overall performance.

--Mohammad

Mohammad

unread,
Mar 17, 2019, 2:20:07 AM3/17/19
to TiddlyWiki
Added to TW-Scripts


On Saturday, March 16, 2019 at 8:01:52 PM UTC+3:30, Jeremy Ruston wrote:
Reply all
Reply to author
Forward
0 new messages