1
0
Fork 0
Commit graph

2 commits

Author SHA1 Message Date
Richard Harrison
bcd59f8370 Nasal PartitionProcessor added time limiter
the partition processor can now either process a certain number of items per frame, or spend a certain amount of time processing items.

The two options work together - so typically you'd pick a sensible amount of items to process per frame and then maybe also set a maximum amount of time per frame to be sure.

Using the time limit option will take slightly more CPU - but can still be a net benefit
2020-10-25 20:02:41 +01:00
Richard Harrison
37729a8661 Added Nasal frame utils: (1) partition processor
The partition processor is a simple class that allows lists of data to be processed in chunks per invocation. It is designed to minimise per frame processing whilst keeping the code simple and the performance acceptable.

test code (use with F-14):

var pptest = func{
    var xx= frame_utils.PartitionProcessor.new("TEST", 6);

    var obj = {}; # just for testing

    for (ii=0;ii<5;ii+=1) {
        xx.process(obj, awg_9.tgts_list,
                   func(pp, obj, data){
                       print("init");
                       obj.designated = -1;
                       obj.search = "Nimitz";
                       obj.completed = 0;
                   }
                   ,
                   func(pp, obj, u){
                       printf("%-5d : %s",pp.data_index, u.Callsign.getValue());

                       if (u.Callsign.getValue() == obj.search)
                         obj.designated = pp.data_index;
                       return 1;
                   },
                   func(pp, obj, data)
                   {
                       obj.completed = 1;
                       printf("Completed: %s = %d\n", obj.search, obj.designated);
                   }
                  );
        if (obj.completed)
          break;
    }
    if (!obj.completed)
      print("partial list processed");
}

pptest();
2020-07-24 15:35:10 +02:00