From 04797fff0eb59337e350afba98772a3a1a2aa63b Mon Sep 17 00:00:00 2001 From: Sergey Patrikeev Date: Tue, 26 May 2020 23:21:38 +0300 Subject: [PATCH] Index diagnostic: add total number of files per file type. GitOrigin-RevId: c82cc63e5d5af9fac37e699ad471c341d161fb25 --- .../diagnostic/IndexDiagnosticJson.kt | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/IndexDiagnosticJson.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/IndexDiagnosticJson.kt index 6e1ffaf07b57..81240b2c5f31 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/IndexDiagnosticJson.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/IndexDiagnosticJson.kt @@ -179,18 +179,32 @@ fun ProjectIndexingHistory.IndexingTimes.convertToJson(): JsonProjectIndexingHis data class JsonProjectIndexingHistory( val projectName: String, - val indexingTimes: JsonProjectIndexingHistoryTimes, val totalNumberOfFiles: Int, + val indexingTimes: JsonProjectIndexingHistoryTimes, + val totalStatsPerFileType: List, val fileProviderStatistics: List -) +) { + data class StatsPerFileType( + val fileType: String, + val totalNumberOfFiles: Int + ) +} -fun ProjectIndexingHistory.convertToJson(): JsonProjectIndexingHistory = - JsonProjectIndexingHistory( +fun ProjectIndexingHistory.convertToJson(): JsonProjectIndexingHistory { + val numberOfFilesPerFileType = hashMapOf() + for (providerStatistic in providerStatistics) { + for (statPerFileType in providerStatistic.statsPerFileType) { + numberOfFilesPerFileType.compute(statPerFileType.fileType) { _, cnt -> (cnt ?: 0) + statPerFileType.numberOfFiles } + } + } + return JsonProjectIndexingHistory( projectName, - times.convertToJson(), providerStatistics.map { it.totalNumberOfFiles }.sum(), + times.convertToJson(), + numberOfFilesPerFileType.map { JsonProjectIndexingHistory.StatsPerFileType(it.key, it.value) }, providerStatistics.sortedByDescending { it.totalIndexingTime.nano } ) +} data class JsonIndexDiagnosticAppInfo( val build: String,