252
edits
mNo edit summary |
No edit summary |
||
Line 63: | Line 63: | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
var path = "/_benchmark/getprop/prop"; | |||
var myprops = []; | var myprops = []; | ||
append(myprops, props.getNode(path, 1)); | |||
var test_getvalue = func { | var test_getvalue = func { | ||
myprops[0].getValue(); | |||
} | |||
var test_setvalue = func { | |||
myprops[0].setValue(21); | |||
} | } | ||
var test_getprop = func { | var test_getprop = func { | ||
var | getprop(path); | ||
} | |||
var test_setprop = func { | |||
setprop(path, 42); | |||
} | } | ||
var init = func { | var init = func { | ||
for (var i = 0; i < repeat; i += 1) { | for (var i = 0; i < repeat; i += 1) { | ||
Line 82: | Line 86: | ||
} | } | ||
} | } | ||
printResult("test_getNode", debug.benchmark_time(init, | printResult("test_getNode", debug.benchmark_time(init, repeat)); | ||
printResult("test_getvalue", debug.benchmark_time(test_getvalue, | printResult("test_getvalue", debug.benchmark_time(test_getvalue, repeat)); | ||
printResult("test_getprop", debug.benchmark_time(test_getprop, | printResult("test_getprop", debug.benchmark_time(test_getprop, repeat)); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 110: | Line 114: | ||
=== Property access === | === Property access === | ||
Repeat count = | Repeat count = 100,000 | ||
It seems that any operation involving a property path (string) is relativly slow. | It seems that any operation involving a property path (string) is relativly slow. | ||
Line 119: | Line 123: | ||
! Test !! Time [s] !! Comment | ! Test !! Time [s] !! Comment | ||
|- | |- | ||
| | | node.setValue() || 0.126 || ~25% faster | ||
|- | |||
| node.getValue() || 0.125 || ~25% faster | |||
|- | |- | ||
| | | setprop() || 0.178 || | ||
|- | |- | ||
| getprop() || 0. | | getprop() || 0.164 || | ||
|} | |} | ||
edits