@@ -59,7 +59,11 @@ namespace vtd {
59
59
* The VtdStatistics struct contains all nominal statistics of the VTD binding.
60
60
*/
61
61
struct VtdStatistics {
62
+ double last_frame_time_ms{0 };
62
63
cloe::utility::Accumulator frame_time_ms;
64
+ cloe::utility::Accumulator task_control_time_ms;
65
+ cloe::utility::Accumulator trigger_and_send;
66
+ cloe::utility::Accumulator data_receive_time_ms;
63
67
cloe::utility::Accumulator clock_drift_ns;
64
68
65
69
/* *
@@ -68,15 +72,22 @@ struct VtdStatistics {
68
72
* # JSON Output
69
73
* ```json
70
74
* {
71
- * {"connection_tries": number},
75
+ * {"last_frame_time_ms", Milliseconds}
72
76
* {"frame_time_ms", Accumulator},
77
+ * {"task_control_time_ms", Accumulator},
78
+ * {"data_receive_time_ms", Accumulator},
79
+ * {"trigger_and_send", Accumulator},
73
80
* {"clock_drift_ns", Accumulator}
74
81
* }
75
82
* ```
76
83
*/
77
84
friend void to_json (cloe::Json& j, const VtdStatistics& s) {
78
85
j = cloe::Json{
86
+ {" last_frame_time_ms" , s.last_frame_time_ms },
79
87
{" frame_time_ms" , s.frame_time_ms },
88
+ {" task_control_time_ms" , s.task_control_time_ms },
89
+ {" data_receive_time_ms" , s.data_receive_time_ms },
90
+ {" trigger_and_send" , s.trigger_and_send },
80
91
{" clock_drift_ns" , s.clock_drift_ns },
81
92
};
82
93
}
@@ -364,8 +375,10 @@ class VtdBinding : public cloe::Simulator {
364
375
assert (operational_);
365
376
366
377
// Statistics:
367
- timer::DurationTimer<timer::Milliseconds> t (
368
- [this ](timer::Milliseconds d) { this ->stats_ .frame_time_ms .push_back (d.count ()); });
378
+ timer::DurationTimer<timer::Milliseconds> t ([this ](timer::Milliseconds d) {
379
+ this ->stats_ .last_frame_time_ms = d.count ();
380
+ this ->stats_ .frame_time_ms .push_back (d.count ());
381
+ });
369
382
370
383
// Read all incoming SCP messages,
371
384
// a) to empty the buffer, and
@@ -378,16 +391,30 @@ class VtdBinding : public cloe::Simulator {
378
391
}
379
392
380
393
// Process task control messages
381
- task_control_->step (sync );
394
+ {
395
+ timer::DurationTimer<timer::Milliseconds> t ([this ](timer::Milliseconds d) {
396
+ this ->stats_ .task_control_time_ms .push_back (d.count ());
397
+ });
398
+ task_control_->step (sync );
399
+ }
382
400
383
401
// Receive new data relating to all sensors
384
402
cloe::Duration sensor_time{0 };
385
- for (auto v : vehicles_) {
386
- sensor_time = v->vtd_step_sensors (sync );
403
+ {
404
+ timer::DurationTimer<timer::Milliseconds> t ([this ](timer::Milliseconds d) {
405
+ this ->stats_ .data_receive_time_ms .push_back (d.count ());
406
+ });
407
+ for (auto v : vehicles_) {
408
+ sensor_time = v->vtd_step_sensors (sync );
409
+ }
387
410
}
388
411
389
412
// Trigger VTD to simulation the next step
390
- task_control_->add_trigger_and_send (sync .step_width ());
413
+ {
414
+ timer::DurationTimer<timer::Milliseconds> t (
415
+ [this ](timer::Milliseconds d) { this ->stats_ .trigger_and_send .push_back (d.count ()); });
416
+ task_control_->add_trigger_and_send (sync .step_width ());
417
+ }
391
418
392
419
// Calculate error of previous timestep for timing statistics
393
420
vtd_timestep_error_ = sync .time () - sensor_time;
0 commit comments