2,736
edits
Red Leader (talk | contribs) (Doc proptrace()) |
Red Leader (talk | contribs) (Doc rank()) |
||
| Line 262: | Line 262: | ||
|param1text = Optional <code>props.Node</code> object, a <code>prop</code> ghost, or a string, all pointing to a property. Defaults to the root of the property tree. | |param1text = Optional <code>props.Node</code> object, a <code>prop</code> ghost, or a string, all pointing to a property. Defaults to the root of the property tree. | ||
|param2 = frames | |param2 = frames | ||
|param2text = | |param2text = Optional number of frames to trace for. Defaults to 2. | ||
|example1 = var n = props.globals.getNode("/demo", 1); | |example1 = var n = props.globals.getNode("/demo", 1); | ||
debug.proptrace("/demo", 10); | debug.proptrace("/demo", 10); | ||
| Line 272: | Line 272: | ||
=== rank() === | === rank() === | ||
{{Nasal doc | {{Nasal doc | ||
|syntax = debug.rank(); | |syntax = debug.rank(list[, repeat]); | ||
|text = | |text = Benchmarks a given list of functions and returns them in a vector with them sorted from fastest to slowest. The result vector will be in the form of <code><nowiki>[[func, time], ...]</nowiki></code>. This result vector can be processed by {{func link|print_rank()|page=this}}. | ||
|param1 = | |param1 = list | ||
|param1text = | |param1text = Vector containing the functions to {{func link|benchmark()|page=this}}. | ||
|example1 = | |param2 = repeat | ||
|param2text = Number of times to repeat each function. | |||
|example1 = var getElev = func(){ | |||
var pos = geo.aircraft_position(); | |||
return geo.elevation(pos.lat(), pos.lon()); | |||
} | |||
var getTime = func(){ | |||
return getprop("/sim/time/gmt"); | |||
} | |||
var list = [getElev, getTime]; | |||
var result = debug.rank(list, 1000); # repeat 1,000 times | |||
debug.dump(result); # getTime() will be first | |||
}} | }} | ||