Add timing data (automatically calculates ns_per_call and calls_per_sec)
| 66 | |
| 67 | /// Add timing data (automatically calculates ns_per_call and calls_per_sec) |
| 68 | void add_timing(int total_calls, fl::u32 elapsed_us) { |
| 69 | fl::i64 elapsed_ns = static_cast<fl::i64>(elapsed_us) * 1000LL; |
| 70 | double ns_per_call = static_cast<double>(elapsed_ns) / total_calls; |
| 71 | double calls_per_sec = 1e9 / ns_per_call; |
| 72 | |
| 73 | m_result.set("total_calls", total_calls); |
| 74 | m_result.set("total_time_ns", elapsed_ns); |
| 75 | m_result.set("ns_per_call", ns_per_call); |
| 76 | m_result.set("calls_per_sec", calls_per_sec); |
| 77 | } |
| 78 | |
| 79 | /// Add custom field to JSON (for comparison/analysis tests) |
| 80 | void set(const char* key, const fl::json& value) { |