Skip to content

Commit

Permalink
[perf-tests] add metric processing time (per file type) to the perf t…
Browse files Browse the repository at this point in the history
…ests for indexing functionality

GitOrigin-RevId: 391eab99952748d79673387fac95417e54902396
  • Loading branch information
annaMarchenkoJetBrains authored and intellij-monorepo-bot committed Nov 3, 2023
1 parent ec568a9 commit e9acc7b
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.intellij.tools.ide.metrics.collector.starter.metrics

import com.intellij.ide.starter.models.IDEStartResult
import com.intellij.openapi.util.text.StringUtil
import com.intellij.tools.ide.metrics.collector.metrics.PerformanceMetrics
import com.intellij.tools.ide.metrics.collector.metrics.toCounterMetricId
import com.intellij.openapi.util.text.StringUtil
import com.intellij.util.indexing.diagnostic.IndexDiagnosticDumper
import com.intellij.util.indexing.diagnostic.dto.*
import com.intellij.util.indexing.diagnostic.dump.paths.PortableFilePath
Expand Down Expand Up @@ -166,6 +166,18 @@ data class IndexingMetrics(
return speedMap
}

private val processingTimePerFileType: Map<String, Long>
get() {
val indexingDurationMap = mutableMapOf<String, Long>()
indexingHistories.forEach { indexingHistory ->
indexingHistory.totalStatsPerFileType.forEach { totalStatsPerFileType ->
val duration = (indexingHistory.times.totalWallTimeWithPauses.nano * totalStatsPerFileType.partOfTotalProcessingTime.partition).toLong()
indexingDurationMap[totalStatsPerFileType.fileType] = indexingDurationMap[totalStatsPerFileType.fileType]?.let { it + duration } ?: duration
}
}
return indexingDurationMap
}

val slowIndexedFiles: Map<String, List<JsonFileProviderIndexStatistics.JsonSlowIndexedFile>>
get() {
val indexedFiles = hashMapOf<String, MutableList<JsonFileProviderIndexStatistics.JsonSlowIndexedFile>>()
Expand Down Expand Up @@ -214,7 +226,8 @@ data class IndexingMetrics(
value = (numberOfIndexedFiles - numberOfFilesFullyIndexedByExtensions).toLong()),
PerformanceMetrics.Metric(metricNumberOfRunsOfScanning, value = totalNumberOfRunsOfScanning.toLong()),
PerformanceMetrics.Metric(metricNumberOfRunsOfIndexing, value = totalNumberOfRunsOfIndexing.toLong())
) + getProcessingSpeedOfFileTypes(processingSpeedPerFileType) + getProcessingSpeedOfBaseLanguages(processingSpeedPerBaseLanguage)
) + getProcessingSpeedOfFileTypes(processingSpeedPerFileType) + getProcessingSpeedOfBaseLanguages(processingSpeedPerBaseLanguage) +
getProcessingTimeOfFileType(processingTimePerFileType)
}
}

Expand Down Expand Up @@ -244,6 +257,11 @@ private fun getProcessingSpeedOfBaseLanguages(mapBaseLanguageToSpeed: Map<String
PerformanceMetrics.Metric("processingSpeedOfBaseLanguage#${it.key}".toCounterMetricId(), value = it.value.toLong())
}

private fun getProcessingTimeOfFileType (mapFileTypeToDuration: Map<String, Long>): List<PerformanceMetrics.Metric> =
mapFileTypeToDuration.map {
PerformanceMetrics.Metric("processingTime#${it.key}".toCounterMetricId(), value = TimeUnit.NANOSECONDS.toMillis(it.value))
}

data class ScanningStatistics(val numberOfScannedFiles: Long = 0, val numberOfSkippedFiles: Long = 0, val totalSumOfThreadTimesWithPauses: Long = 0) {
fun merge(scanningStatistics: JsonScanningStatistics) : ScanningStatistics {
return ScanningStatistics(
Expand Down

0 comments on commit e9acc7b

Please sign in to comment.