dashboard: add api timing diagnostics
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
static const char *DASHBOARD_VERSION = "0.0.9-status-fields";
|
||||
static const char *DASHBOARD_VERSION = "0.0.10-api-timing";
|
||||
|
||||
// Update these if your Cargo ESP AP credentials are different.
|
||||
static const char *CARGO_WIFI_SSID = "OverlandController";
|
||||
|
||||
@@ -468,13 +468,21 @@ static bool fetch_status_fields(const char *url, const char *label)
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long start_ms = millis();
|
||||
|
||||
Serial.print("GET ");
|
||||
Serial.println(url);
|
||||
|
||||
HTTPClient http;
|
||||
http.setTimeout(5000);
|
||||
|
||||
unsigned long begin_start_ms = millis();
|
||||
http.begin(url);
|
||||
unsigned long begin_ms = millis() - begin_start_ms;
|
||||
|
||||
unsigned long get_start_ms = millis();
|
||||
int code = http.GET();
|
||||
unsigned long get_ms = millis() - get_start_ms;
|
||||
|
||||
status_model.http_code = code;
|
||||
|
||||
@@ -483,17 +491,46 @@ static bool fetch_status_fields(const char *url, const char *label)
|
||||
Serial.println(code);
|
||||
|
||||
if (code == 200) {
|
||||
unsigned long body_start_ms = millis();
|
||||
String body = http.getString();
|
||||
unsigned long body_ms = millis() - body_start_ms;
|
||||
|
||||
Serial.print(label);
|
||||
Serial.print(" body length: ");
|
||||
Serial.println(body.length());
|
||||
|
||||
unsigned long parse_start_ms = millis();
|
||||
parse_status_json(body);
|
||||
unsigned long parse_ms = millis() - parse_start_ms;
|
||||
|
||||
unsigned long total_ms = millis() - start_ms;
|
||||
|
||||
Serial.print("TIMING ");
|
||||
Serial.print(label);
|
||||
Serial.print(" begin=");
|
||||
Serial.print(begin_ms);
|
||||
Serial.print("ms get=");
|
||||
Serial.print(get_ms);
|
||||
Serial.print("ms body=");
|
||||
Serial.print(body_ms);
|
||||
Serial.print("ms parse+ui=");
|
||||
Serial.print(parse_ms);
|
||||
Serial.print("ms total=");
|
||||
Serial.print(total_ms);
|
||||
Serial.print("ms bytes=");
|
||||
Serial.println(body.length());
|
||||
|
||||
http.end();
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long total_ms = millis() - start_ms;
|
||||
Serial.print("TIMING ");
|
||||
Serial.print(label);
|
||||
Serial.print(" failed total=");
|
||||
Serial.print(total_ms);
|
||||
Serial.println("ms");
|
||||
|
||||
status_model.api_ok = false;
|
||||
|
||||
String system;
|
||||
|
||||
Reference in New Issue
Block a user