Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thermal status to benchmark results #3051

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package org.maplibre.android.testapp.activity.benchmark

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.os.Handler
import android.os.PowerManager
import android.view.View
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -188,7 +190,23 @@ class BenchmarkActivity : AppCompatActivity() {
}
}

private fun getThermalStatus(): Int {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
return powerManager.currentThermalStatus
}

return -1;
}

private fun setupMapView() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
powerManager.addThermalStatusListener {
status -> println("Thermal status changed $status")
}
}

mapView = findViewById<View>(R.id.mapView) as MapView
mapView.getMapAsync { maplibreMap: MapLibreMap ->
val benchmarkResult = BenchmarkResult(arrayListOf())
Expand Down Expand Up @@ -254,7 +272,7 @@ class BenchmarkActivity : AppCompatActivity() {

mapView.removeOnDidFinishRenderingFrameListener(listener)

return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore)
return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore, getThermalStatus())
}

override fun onStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ data class BenchmarkRun(
data class BenchmarkRunResult(
val fps: Double,
val encodingTimeStore: FrameTimeStore,
val renderingTimeStore: FrameTimeStore
val renderingTimeStore: FrameTimeStore,
val thermalState: Int
)

data class BenchmarkResult (
Expand All @@ -46,6 +47,7 @@ fun jsonPayload(benchmarkResult: BenchmarkResult): JsonObject {
addJsonObject {
put("styleName", JsonPrimitive(run.first.styleName))
put("syncRendering", JsonPrimitive(run.first.syncRendering))
put("thermalState", JsonPrimitive(run.second.thermalState))
put("fps", JsonPrimitive(run.second.fps))
put("avgEncodingTime", JsonPrimitive(run.second.encodingTimeStore.average()))
put("avgRenderingTime", JsonPrimitive(run.second.renderingTimeStore.average()))
Expand Down
Loading