TP-12345 | Macrobenchmarking for app startup and homepage scroll [CICD] (#11461)

Co-authored-by: Ujjwal Kumar <ujjwal.kumar@navi.com>
Co-authored-by: Anupam Kumar <anupam.kumar@navi.com>
Co-authored-by: Shivam Goyal <shivam.goyal@navi.com>
This commit is contained in:
nikhil kumar
2024-07-24 14:05:38 +05:30
committed by GitHub
parent f03d630a00
commit 40bdcee97a
8 changed files with 176 additions and 90 deletions

View File

@@ -0,0 +1,68 @@
import json
import requests
import sys
def send_message_to_metabase(device_model, version_code, run_id, min, median, max, homepage_p50,
homepage_p90, homepage_p95, homepage_p99):
url = "https://janus.prod.navi-tech.in/events/json"
headers = {
"Content-Type": "application/json"
}
data = {
"events": [
{
"event_name": "NaviApp_Startup_Benchmark",
"attributes": {
"min": round(min),
"median": round(median),
"max": round(max),
"run_id": run_id,
"version_code": version_code,
"device_model": device_model,
"source": "android"
}
},
{
"event_name": "NaviApp_HomePage_Scroll_Benchmark",
"attributes": {
"p50_frame_duration": round(homepage_p50),
"p90_frame_duration": round(homepage_p90),
"p95_frame_duration": round(homepage_p95),
"p99_frame_duration": round(homepage_p99),
"run_id": run_id,
"version_code": version_code,
"device_model": device_model,
"source": "android"
}
}
],
"source": "Android-Macrobenchmark"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code != 200:
raise Exception(
f"Request to Metabase API failed with status code {response.status_code}: {response.text}")
else:
print("Message posted successfully.")
if __name__ == "__main__":
run_id = sys.argv[1]
version_code = sys.argv[2]
with open('macrobenchmark_results.json', 'r') as file_current:
benchmark_file = json.load(file_current)
benchmark = benchmark_file['benchmarks']
homePage_metrics = benchmark[0]['sampledMetrics']['frameDurationCpuMs']
p50_value = homePage_metrics['P50']
p90_value = homePage_metrics['P90']
p95_value = homePage_metrics['P95']
p99_value = homePage_metrics['P99']
startup_metrics = benchmark[1]['metrics']['timeToInitialDisplayMs']
median_value = startup_metrics['median']
min_value = startup_metrics['minimum']
max_value = startup_metrics['maximum']
context = benchmark_file['context']
device_model = context['build']['model']
send_message_to_metabase(device_model, version_code, run_id, min_value, median_value, max_value,
p50_value, p90_value, p95_value, p99_value)