Nasal performance and benchmarks: Difference between revisions

Jump to navigation Jump to search
no edit summary
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 = [];
var path = "/_benchmark/getprop/prop";
append(myprops, props.getNode(path, 1));
 
var test_getvalue = func {
var test_getvalue = func {
     var test = 0;
     myprops[0].getValue();
    forindex (i; myprops) {
}
        t = myprops[i].getValue();
var test_setvalue = func {
    }
    myprops[0].setValue(21);
}
}
var test_getprop = func {
var test_getprop = func {
     var test = 0;
     getprop(path);
     forindex (i; myprops) {
}
        t = getprop(path~i);
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, 1));
printResult("test_getNode", debug.benchmark_time(init, repeat));
printResult("test_getvalue", debug.benchmark_time(test_getvalue, 1));
printResult("test_getvalue", debug.benchmark_time(test_getvalue, repeat));
printResult("test_getprop", debug.benchmark_time(test_getprop, 1));
printResult("test_getprop", debug.benchmark_time(test_getprop, repeat));
</syntaxhighlight>
</syntaxhighlight>


Line 110: Line 114:


=== Property access ===
=== Property access ===
Repeat count = 10000
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
|-
|-
| props.getNode() || 0.420 ||  
| node.setValue() || 0.126 || ~25% faster
|-
| node.getValue() || 0.125 || ~25% faster
|-
|-
| node.getValue() || 0.010 || using a node object is 36-40 times faster
| setprop() || 0.178 ||  
|-
|-
| getprop() || 0.368 ||  
| getprop() || 0.164 ||  
|}
|}


252

edits

Navigation menu