-
Notifications
You must be signed in to change notification settings - Fork 119
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
refactor: Refactor data scratch-performance metrics #1840
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
test_runner/src/main/kotlin/ftl/adapter/GooglePerformanceMetricsFetch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ftl.adapter | ||
|
||
import ftl.adapter.google.toApiModel | ||
import ftl.adapter.google.toClientModel | ||
import ftl.api.PerfMetrics | ||
import ftl.gc.GcToolResults | ||
|
||
object GooglePerformanceMetricsFetch : | ||
PerfMetrics.Fetch, | ||
(PerfMetrics.Identity) -> PerfMetrics.Summary by { identity -> | ||
GcToolResults.getPerformanceMetric(identity.toClientModel()).toApiModel() | ||
} |
64 changes: 64 additions & 0 deletions
64
test_runner/src/main/kotlin/ftl/adapter/google/PerfMetricsAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package ftl.adapter.google | ||
|
||
import com.google.api.services.toolresults.model.AppStartTime | ||
import com.google.api.services.toolresults.model.CPUInfo | ||
import com.google.api.services.toolresults.model.GraphicsStats | ||
import com.google.api.services.toolresults.model.GraphicsStatsBucket | ||
import com.google.api.services.toolresults.model.MemoryInfo | ||
import com.google.api.services.toolresults.model.PerfEnvironment | ||
import com.google.api.services.toolresults.model.PerfMetricsSummary | ||
import com.google.testing.model.ToolResultsStep | ||
import ftl.api.PerfMetrics | ||
import ftl.util.Duration | ||
import com.google.api.services.toolresults.model.Duration as GoogleApiDuration | ||
|
||
internal fun PerfMetrics.Identity.toClientModel(): ToolResultsStep = | ||
ToolResultsStep() | ||
.setHistoryId(historyId) | ||
.setExecutionId(executionId) | ||
.setStepId(stepId) | ||
.setProjectId(projectId) | ||
|
||
internal fun PerfMetricsSummary.toApiModel(): PerfMetrics.Summary = PerfMetrics.Summary( | ||
appStartTime = appStartTime?.toApiModel(), | ||
graphicsStats = graphicsStats?.toApiModel(), | ||
perfEnvironment = perfEnvironment?.toApiModel(), | ||
perfMetrics = perfMetrics.orEmpty(), | ||
executionId = executionId.orEmpty(), | ||
historyId = historyId.orEmpty(), | ||
projectId = projectId.orEmpty(), | ||
stepId = stepId.orEmpty() | ||
) | ||
|
||
private fun PerfEnvironment.toApiModel() = PerfMetrics.PerfEnvironment( | ||
cpuInfo = cpuInfo?.toApiModel(), | ||
memoryInfo = memoryInfo?.toApiModel() | ||
) | ||
|
||
private fun CPUInfo.toApiModel() = PerfMetrics.CPUInfo(cpuProcessor, cpuSpeedInGhz, numberOfCores) | ||
|
||
private fun MemoryInfo.toApiModel() = PerfMetrics.MemoryInfo(memoryCapInKibibyte, memoryTotalInKibibyte) | ||
|
||
private fun GraphicsStats.toApiModel() = PerfMetrics.GraphicsStats( | ||
buckets = buckets?.mapNotNull { bucket -> bucket?.toApiModel() }, | ||
highInputLatencyCount = highInputLatencyCount, | ||
jankyFrames = jankyFrames, | ||
missedVsyncCount = missedVsyncCount, | ||
p50Millis = p50Millis, | ||
p90Millis = p90Millis, | ||
p95Millis = p95Millis, | ||
p99Millis = p99Millis, | ||
slowBitmapUploadCount = slowBitmapUploadCount, | ||
slowDrawCount = slowDrawCount, | ||
slowUiThreadCount = slowUiThreadCount, | ||
totalFrames = totalFrames | ||
) | ||
|
||
private fun GraphicsStatsBucket.toApiModel() = PerfMetrics.GraphicsStats.Bucket(frameCount, renderMillis) | ||
|
||
private fun AppStartTime.toApiModel() = PerfMetrics.AppStartTime( | ||
fullyDrawnTime = fullyDrawnTime?.toApiModel(), | ||
initialDisplayTime = initialDisplayTime?.toApiModel() | ||
) | ||
|
||
private fun GoogleApiDuration.toApiModel() = Duration(seconds ?: 0, nanos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ftl.api | ||
|
||
import ftl.adapter.GooglePerformanceMetricsFetch | ||
import ftl.util.Duration | ||
|
||
val fetchPerformanceMetrics: PerfMetrics.Fetch get() = GooglePerformanceMetricsFetch | ||
|
||
object PerfMetrics { | ||
|
||
data class Summary( | ||
val appStartTime: AppStartTime? = null, | ||
val graphicsStats: GraphicsStats? = null, | ||
val perfEnvironment: PerfEnvironment? = null, | ||
val perfMetrics: List<String>? = null, | ||
val executionId: String? = null, | ||
val historyId: String? = null, | ||
val projectId: String? = null, | ||
val stepId: String? = null, | ||
) | ||
|
||
data class GraphicsStats( | ||
val buckets: List<Bucket>? = null, | ||
val highInputLatencyCount: Long? = null, | ||
val jankyFrames: Long? = null, | ||
val missedVsyncCount: Long? = null, | ||
val p50Millis: Long? = null, | ||
val p90Millis: Long? = null, | ||
val p95Millis: Long? = null, | ||
val p99Millis: Long? = null, | ||
val slowBitmapUploadCount: Long? = null, | ||
val slowDrawCount: Long? = null, | ||
val slowUiThreadCount: Long? = null, | ||
val totalFrames: Long? = null, | ||
) { | ||
data class Bucket( | ||
val frameCount: Long?, | ||
val renderMillis: Long?, | ||
) | ||
} | ||
|
||
data class AppStartTime( | ||
val fullyDrawnTime: Duration? = null, | ||
val initialDisplayTime: Duration? = null, | ||
) | ||
|
||
data class PerfEnvironment( | ||
val cpuInfo: CPUInfo? = null, | ||
val memoryInfo: MemoryInfo? = null, | ||
) | ||
|
||
data class CPUInfo( | ||
val cpuProcessor: String? = null, | ||
val cpuSpeedInGhz: Float? = null, | ||
val numberOfCores: Int? = null, | ||
) | ||
|
||
data class MemoryInfo( | ||
val memoryCapInKibibyte: Long? = null, | ||
val memoryTotalInKibibyte: Long? = null, | ||
) | ||
|
||
data class Identity( | ||
val executionId: String, | ||
val historyId: String, | ||
val projectId: String, | ||
val stepId: String, | ||
) | ||
|
||
interface Fetch : (Identity) -> Summary | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If seconds is in Long, should not nanos be Long too? It potentially can be a larger number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is copy-pasted from google api 🙉