Closed back2dos closed 5 years ago
Seems to be 50:50 for me on what runs faster (tested the thing like 30 times on chrome 69.0.3497.92). Times ranging from: 0.36 - 0.45 for both. Similar results for edge 42.17134.1.0, except a lot slower with times ranging from 0.6 - 0.8.
16:44:00:316 Test.hx:10: fill
16:44:00:717 Test.hx:23: 0.40000009536743164s
16:44:00:717 Test.hx:10: fill
16:44:01:166 Test.hx:30: 0.44699978828430176s
16:45:00:219 Test.hx:10: fill
16:45:00:621 Test.hx:23: 0.40000009536743164s
16:45:00:621 Test.hx:10: fill
16:45:01:014 Test.hx:30: 0.3900001049041748s
16:45:25:576 Test.hx:10: fill
16:45:25:989 Test.hx:23: 0.41100001335144043s
16:45:25:990 Test.hx:10: fill
16:45:26:374 Test.hx:30: 0.38300013542175293s
16:49:39:364 Test.hx:10: fill
16:49:39:753 Test.hx:23: 0.38700008392333984s
16:49:39:753 Test.hx:10: fill
16:49:40:158 Test.hx:30: 0.4029998779296875s
Interesting. For me on Chrome it's slightly faster for onclick, but FF is roughly equal. I have another one, that simulates something slightly closer to what patching does (i.e. replacing handlers): https://try.haxe.org/#AEfB4 ... seems to tend more clearly towards onclick
. But well, useful benchmarking is not that easy ...
Yes, in the 2nd test onClick
seems consistently faster for me as well.
I'm just going to file this under "fast enough". In any case https://github.com/MVCoconut/coconut.ui/issues/31 should have more significant effects than microoptimizing handlers.
A simple benchmark on Chrome seems to indicate that setting
onclick
is faster thanaddEventListener('click')
: https://try.haxe.org/#c3d21Should properly verify across browser and make the diffing work accordingly.