Performance comparision between [is[current]] and <currentTiddler>

238 views
Skip to first unread message

Danielo Rodríguez

unread,
Jun 11, 2017, 11:31:32 AM6/11/17
to TiddlyWiki
Hello,

I was creating some template tiddlers when I suddenly discovered myself using <currentTiddler> a lot within list widgets.

This is what was natural for me at that moment, but I just remembered that I before I normally use the filter operator [is[current]] or [all[current]] and the doubt appeared. Which one has better performance? Using the <currentTiddler> variable or the [is[current]] filter operator.

For me makes sense that just accessing a variable is much more performant than just filtering all the tiddlers to see which one is the current one. One usage example is as follows:


<$list filter="[<currentTiddler>has[text]]">
 Text if the field exists
</$list>
<$list filter="[<currentTiddler>!has[text]]">
  Text if the field does not exist
</$list>

Maybe there are situations where you want to use the filter version instead of the variable, but since both depend on the value of the current tiddler variable, I can't think of any situation like this.

Any reasoning about this is very welcome. If currentTiddler is more performant for this base cases, I think it should be included as some part of good practices or something like this.

Regards 

Danielo Rodríguez

unread,
Jun 26, 2017, 2:30:12 PM6/26/17
to TiddlyWiki
Nobody has an opinion about this ? Or a measurement? Or an rough idea ?

@TiddlyTweeter

unread,
Jun 26, 2017, 2:43:26 PM6/26/17
to TiddlyWiki
I DO NOT know the answer. But I do think its a very good question. IN FACT the whole question of Performance in TW deserves a lot more attention IMO. Erwan did one interesting, thorough, performance study that showed that use of tags can impair performance. Its the only documented performance study I know of.

Mark S.

unread,
Jun 26, 2017, 4:15:13 PM6/26/17
to TiddlyWiki
My informal test, running the code below on  TiddlyWiki.com, suggests that <currentTiddler> may be twice as fast as is[current]. Minutes and seconds are posted at the top and bottom of the process loop for comparison.

<<now "mm:0ss">>
<$list filter="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20">
<$list filter="[all[tiddlers+shadows]]">
<$list filter="[
<currentTiddler>has[text]]">
 .</$list>
</$list>
</$list>
<
<now "mm:0ss">>

@TiddlyTweeter

unread,
Jun 26, 2017, 4:59:35 PM6/26/17
to TiddlyWiki
WHOAH! Is that a proto Test Suite?

Arlen Beiler

unread,
Jun 26, 2017, 7:44:45 PM6/26/17
to TiddlyWiki
Brilliant!!! Here is my test and result

<<now "mm:0ss">> <-- 41:23

<$list filter="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20">
<$list filter="[all[tiddlers+shadows]]">
<$list filter="[<currentTiddler>has[text]]"> </$list>
</$list>
</$list>
<<now "mm:0ss">> <-- 41:27 (4 seconds)

<$list filter="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20">
<$list filter="[all[tiddlers+shadows]]">
<$list filter="[is[current]has[text]]"> </$list>
</$list>
</$list>
<<now "mm:0ss">> <-- 41:31 (4 seconds)

Apparently no significant difference. 



--
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+unsubscribe@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/1dbc1104-1500-4409-a34b-401384cfcef6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mat

unread,
Jun 26, 2017, 7:59:10 PM6/26/17
to tiddl...@googlegroups.com
Had no idea one could do this! Here are my results, running it on tiddlywiki.com on my win10 chrome:

49:16
49:27 <– 11 seconds for <currentTiddler>
49:54 <– 27 seconds for is[current]

switching places (no idea if that makes sense but anyway):

53:57
54:25 <– 28 sec for is[current]
54:40 <– 15 sec for <currentTiddler>

Winner: <currentTiddler> at about half the time!

Mark S.

unread,
Jun 26, 2017, 8:10:51 PM6/26/17
to TiddlyWiki
Hi Arlen,

What is your setup? Nodejs or stand-alone? Which browser, what OS, and what kind of machine. I'm thinking that if you can zip through these in 4 seconds that you might need to load the first list filter some more.

Mark
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.

Arlen Beiler

unread,
Jun 26, 2017, 8:24:56 PM6/26/17
to TiddlyWiki
It was on an almost empty TiddlyWiki datafolder mounted in TiddlyServer (which currently uses $:/core/save/all), so just a stock TiddlyWiki with hardly anything in it. I didn't think about it that I was using an almost empty TiddlyWiki or I would have mentioned it! :)

 Windows 7 64 Bit / Chrome current stable. 

To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscribe@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Arlen Beiler

unread,
Jun 26, 2017, 8:47:55 PM6/26/17
to TiddlyWiki
IN FACT the whole question of Performance in TW deserves a lot more attention IMO.

The performance has improved a lot since the early versions of TiddlyWiki5. I remember some of the early advances between 5.0.4 (when popups took a second to open) and 5.0.14 (400 ms or so). Now they are nearly instantaneous! So work has been done, but filters is one that does still need it. One only has to open the list of shadow tiddlers to get a good benchmark. But that time has improved too.

Maybe we could compile filters...

Evolena

unread,
Jun 27, 2017, 7:15:46 AM6/27/17
to TiddlyWiki
Hello,

is[current] is a selection modifier, so it acts on a selection of tiddlers. If you don't select tiddlers beforehand with a selection constructor (all, title, list, ...), it operates on all[tiddlers] by default. So in order to select directly the current tiddler, the best operator is all[current]. is[current] is better used for checking if a tiddler amongst a tiddlers previously selected is the currentTiddler, it should not be used as a first step.

If you run your test, you can see that all[current] has approximatively the same performances as <currentTiddler>.

NB
This commit introduced the all[current] instead of is[current] whose two roles as selector and modifier were misleading.
I think there has been discussions about is[current] and all[current] in the past years, but... "all is current operator" is not a distinctive search enough...

Danielo Rodríguez

unread,
Jun 27, 2017, 1:23:14 PM6/27/17
to TiddlyWiki
To be honest, for me the current API is quite confusing.

all[current]  seems odd to me. Makes me think I am going to iterate all the tiddlers just to get the current one. Which is more or less what I though is[current] does.
In the documentation we should make clearer that is[current] to select the current tiddler is discouraged.

Regards

Mark S.

unread,
Jun 27, 2017, 2:05:53 PM6/27/17
to TiddlyWiki
Yes. Or maybe, just for consistency, there should be a "current[]" filter operator.

Evolena

unread,
Jun 27, 2017, 2:13:42 PM6/27/17
to tiddl...@googlegroups.com
Maybe the name is not the more intuitive, but the Javascript code is clear : [all[current]] doesn't iterate each tiddler (as all[missing] or all[orphans] do), it simply returns the currentTiddler variable if it exists, and an empty list if it doesn't. While [is[current]] without any selector implicitely iterates over all[tiddlers] (and so, the selection of tiddlers will become empty if the currentTiddler happens to be a pure shadow tiddler, see PS below).
I think is[current] only remains for backward compatibility, I've never seen it used where all[current] wouldn't do the job.

But <currentTiddler> is clear, and can be used instead of all[current] with similar performances (maybe only a difference if there is no tiddler in the currentTiddler variable, but I don't think so), so pick the one you prefer :)

PS: You can try this:

<$tiddler tiddler="$:/Acknowledgements">

; `[all[current]]`
: <$list filter="[all[current]]" emptyMessage="No result"/>
; `[<currentTiddler>]`
: <$list filter="[<currentTiddler>]" emptyMessage="No result"/>
; `[is[current]]`
: <$list filter="[is[current]]" emptyMessage="No result"/>
; `[all[shadows]is[current]]`
: <$list filter="[all[shadows]is[current]]" emptyMessage="No result"/>
; `[all[tiddlers]is[current]]`
: <$list filter="[all[tiddlers]is[current]]" emptyMessage="No result"/>
</$tiddler>

Danielo Rodríguez

unread,
Jun 28, 2017, 6:21:28 AM6/28/17
to TiddlyWiki
 [all[current]] doesn't iterate each tiddler (as all[missing] or all[orphans] do)

That's exactly the kind of inconsistency I'm talking about. Personally I have very low confidence on my memory, and this kind of situation, where 99% of the times things behaves one way and there is an 1% that behaves differently really confuses me. I will always doubt and thing it works the opposite it does (that is how my brain works, sorry). That's why having something so clear as <currentTiddler> is important to me. Now that I know it has the same performance I will always use it.

Regards

Evolena

unread,
Jun 28, 2017, 1:43:36 PM6/28/17
to tiddl...@googlegroups.com
You shouldn't think of the all operator as "iterate over all tiddlers to find the one corresponding to the operand", but as "select all tiddlers corresponding to the operand" (as the name "selector operator" suggests). That the implementation does or does not iterate over every tiddler is a completely separate fact. Even if "select all current tiddlers" happens to result in only one tiddler, it has helped me to remind the semantic of the operator; first I select, then I filter.

Le mercredi 28 juin 2017 12:21:28 UTC+2, Danielo Rodríguez a écrit :
That's why having something so clear as <currentTiddler> is important to me.Now that I know it has the same performance I will always use it.

That's the only important thing :)
And I agree that <currentTiddler> is unambiguous !

@TiddlyTweeter

unread,
Jun 28, 2017, 1:47:12 PM6/28/17
to TiddlyWiki
A question from an idiot.

WHICH of the options should I USE? I'm really not interested in how we got here, only in what works best, NOW.

Josiah

Mark S.

unread,
Jun 28, 2017, 2:00:21 PM6/28/17
to TiddlyWiki
Based on the discussion, "all[current]" or "<currentTIddler>" but not "is[current]".

Mark
Reply all
Reply to author
Forward
0 new messages