Since today there's a function  systime()  available. It returns 
the Unix Epoch time in seconds. Even if that doesn't tell you much,
it's very useful for benchmarking:

  var start = systime();
  how_fast_am_I(123);
  var end = systime();

  print("took ", end - start, " seconds");

The function has microseconds precision, so it's even useful for
single function calls. But you can always let the code be run in
a loop for better results. In debug.nas there's a simple wrapper
that would do the same in one line:

  debug.benchmark("test", how_fast_am_I, 123);

or 

  debug.benchmark("test", func {
      how_fast_am_I(123);
  });




The second change today is a new props.Node method getValues().
It returns a subtree's values in a hash, just like the setValues()
method expects its input. This can be used to suck in a group of
parameters. Of course, it only makes sense if all or almost all
parameters are needed, and not to retrieve single values as in
the example:

  var view = props.Node.getNode("/sim/current-view");
  var val = view.getValues();
  print(val["config"]["default-field-of-view-deg"]);

And yes, you can load the whole property tree into a variable:  :-)

  var v = props.globals.getValues();
  debug.dump(v);

m.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to