Pre-requisites :
Access to the API (Greenspector account)
Private token (On http://app.greenspector.com/ , click on your username then Preferences)
URL of the website to benchmark
Swagger de l’API : https://app.greenspector.com/api/ui/#
Create an application
Target URL : https://app.greenspector.com
URI : /api/applications
Method : POST
Headers :
Content-Type: "application/json"
Private-Token: user’s private token
Body :
{ "name" : "My App" , "description" : "Description" } |
Create a job request
Target URL : https://app.greenspector.com
URI : /api/testbench/jobs
Method : POST
Headers :
Content-Type: "application/json"
Private-Token: user’s private token
Body :
{ "application" : "My app" , "version" : "My version (string)" , "job" : { "mode" : "url" , "scenario" : "avance" , "iterations" : 1 , "cache" : false , "browser" : "chrome" , "networkMode" : "WIFI" }, "environment" : { "platform" : "mobile" , "os" : "android" , "version" : "8" , "device" : "Samsung - Galaxy S7" } } |
Example :
{ "application" : "My app" , "version" : "1.0.0" , "job" : { "mode" : "url" , "scenario" : "avance" , "iterations" : 1 , "cache" : false , "browser" : "chrome" , "networkMode" : "WIFI" }, "environment" : { "platform" : "mobile" , "os" : "android" , "version" : "8" , "device" : "Samsung - Galaxy S7" } } |
Response :
{ "applicationId" : 1 , "auditId" : 2 , "jobId" : 3 } |
Supervise job state
Target URL : https://app.greenspector.com
URI : /api/testbench/jobs/:jobId
Method : GET
Headers :
Private-Token: user’s private token
Response :
{ "id" : :jobId, "status" : "finished" , "errors" : [], "startDate" : "2021-01-18T10:01:17.000Z" , "endDate" : "2021-01-18T10:04:25.000Z" , "mode" : "url" , "browser" : "chrome" , "url" : "" , "TestsStatus" : [ [ { "Dumpsys" : false , "IterationID" : "1" , "Logs" : "" , "StackTrace" : "" , "Status" : "success" , "TestGroupName" : "" , "TestName" : "Benchmark URL" } ] ], "TestBenchEnvironment" : { "platform" : "mobile" , "os" : "android" , "version" : "8" , "device" : "Samsung - Galaxy S7" } } |
Retrieve the job’s report :
Target URL : https://app.greenspector.com
URI : /api/audits/:auditId/report
Method : GET
Headers :
Private-Token: user’s private token
Response :
{ "application" : { "name" : "My app" , "id" : 1 }, "audit" : { "version" : "1.0.0" , "id" : 2 }, "summary" : { "ecoscore" : { "global" : 57 , "network" : 75 , "clientresources" : 39 }, "budgets" : { "notConfigured" : 4 , "total" : 4 }, "tests" : { "total" : 1 , "failed" : 0 }, "improvements" : { "critical" : 5 , "major" : 3 , "good" : 5 } }, "improvements" : [ { "name" : "Minimize impact on platform discharge on mobile during background idle step" , "priority" : 4 , "score" : 11.11 , "gain" : 0 } ], "benchmark" : { "pc" : [], "mobile" : [ { "name" : "reference_mobile_apk" , "order" : 1 , "networkMode" : "WIFI" , "metrics" : { "AH_PL" : { "value" : 960464 }, "AH_PL/s" : { "value" : 49303.9 }, "C_ID" : { "value" : 0 }, "C_PL" : { "value" : 13.5627 }, "D_ID" : { "value" : 0 }, "D_IN_ID" : { "value" : 0 }, "D_OUT_ID" : { "value" : 0 }, "M_ID" : { "value" : 0 }, "M_PL" : { "value" : 1456320 }, "MAX_O_DPacket_ID" : { "value" : 0 }, "PMAX_PL" : { "value" : 1700.64 }, "TOTAL_O_DPacket_ID" : { "value" : 0 }, "TT_PL" : { "value" : 20132 }, "O_Activities" : { "value" : 0 }, "O_AppContexts" : { "value" : 0 }, "O_AssetManagers" : { "value" : 0 }, "O_Assets" : { "value" : 0 }, "O_Death_Recipients" : { "value" : 0 }, "O_OpenSSL_Sockets" : { "value" : 0 }, "O_ViewRootImpl" : { "value" : 0 }, "O_Views" : { "value" : 0 }, "SQL_MALLOC_SIZE" : { "value" : 0 }, "SQL_MEMORY_USED" : { "value" : 0 }, "SQL_PAGECACHE_OVERFLOW" : { "value" : 0 } } }, { "name" : "initial_load_mobile_url" , "order" : 2 , "networkMode" : "WIFI" , "metrics" : {...} }, { "name" : "initial_idle_mobile_url" , "order" : 3 , "networkMode" : "WIFI" , "metrics" : {...} }, { "name" : "initial_scroll_mobile_url" , "order" : 4 , "networkMode" : "WIFI" , "metrics" : {...} }, { "name" : "initial_background_mobile_url" , "order" : 5 , "networkMode" : "WIFI" , "metrics" : {...} } ], "apk" : [] }, "tests" : [] } |