mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Index diagnostic: rename MaxNTimeBucket to TimeStats.
GitOrigin-RevId: bf882d96e157d49d47b7653ad3ff976551e2c00b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
04797fff0e
commit
0732bbb74e
@@ -59,7 +59,7 @@ data class JsonTimeStats(
|
||||
}
|
||||
}
|
||||
|
||||
fun MaxNTimeBucket.toTimeStats(): JsonTimeStats? {
|
||||
fun TimeStats.toTimeStats(): JsonTimeStats? {
|
||||
if (isEmpty) {
|
||||
return null
|
||||
}
|
||||
|
||||
+9
-9
@@ -4,31 +4,31 @@ package com.intellij.util.indexing.diagnostic
|
||||
class IndexingJobStatistics {
|
||||
private val timeBucketSize = 128
|
||||
|
||||
val timesPerIndexer: Map<String /* ID.name() */, MaxNTimeBucket>
|
||||
val timesPerIndexer: Map<String /* ID.name() */, TimeStats>
|
||||
get() = _timesPerIndexer
|
||||
|
||||
val indexingTimesPerFileType: Map<String /* File type name */, MaxNTimeBucket>
|
||||
val indexingTimesPerFileType: Map<String /* File type name */, TimeStats>
|
||||
get() = _indexingTimesPerFileType
|
||||
|
||||
val contentLoadingTimesPerFileType: Map<String /* File type name */, MaxNTimeBucket>
|
||||
val contentLoadingTimesPerFileType: Map<String /* File type name */, TimeStats>
|
||||
get() = _contentLoadingTimesPerFileType
|
||||
|
||||
val numberOfFilesPerFileType: Map<String /* File type name */, Int>
|
||||
get() = _numberOfFilesPerFileType
|
||||
|
||||
private val _timesPerIndexer = hashMapOf<String, MaxNTimeBucket>()
|
||||
private val _indexingTimesPerFileType = hashMapOf<String, MaxNTimeBucket>()
|
||||
private val _contentLoadingTimesPerFileType = hashMapOf<String, MaxNTimeBucket>()
|
||||
private val _timesPerIndexer = hashMapOf<String, TimeStats>()
|
||||
private val _indexingTimesPerFileType = hashMapOf<String, TimeStats>()
|
||||
private val _contentLoadingTimesPerFileType = hashMapOf<String, TimeStats>()
|
||||
private val _numberOfFilesPerFileType = hashMapOf<String, Int>()
|
||||
|
||||
@Synchronized
|
||||
fun addFileStatistics(fileStatistics: FileIndexingStatistics, contentLoadingTime: Long) {
|
||||
fileStatistics.perIndexerTimes.forEach { (indexId, time) ->
|
||||
_timesPerIndexer.getOrPut(indexId.name) { MaxNTimeBucket(timeBucketSize) }.addTime(time)
|
||||
_timesPerIndexer.getOrPut(indexId.name) { TimeStats(timeBucketSize) }.addTime(time)
|
||||
}
|
||||
val fileTypeName = fileStatistics.fileType.name
|
||||
_numberOfFilesPerFileType.compute(fileTypeName) { _, currentNumber -> (currentNumber ?: 0) + 1 }
|
||||
_indexingTimesPerFileType.computeIfAbsent(fileTypeName) { MaxNTimeBucket(timeBucketSize) }.addTime(fileStatistics.indexingTime)
|
||||
_contentLoadingTimesPerFileType.computeIfAbsent(fileTypeName) { MaxNTimeBucket(timeBucketSize) }.addTime(contentLoadingTime)
|
||||
_indexingTimesPerFileType.computeIfAbsent(fileTypeName) { TimeStats(timeBucketSize) }.addTime(fileStatistics.indexingTime)
|
||||
_contentLoadingTimesPerFileType.computeIfAbsent(fileTypeName) { TimeStats(timeBucketSize) }.addTime(contentLoadingTime)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import java.util.*
|
||||
* Bucket of times with size of at most [sizeLimit].
|
||||
* Maintains exact min, max, mean of all added times.
|
||||
*/
|
||||
class MaxNTimeBucket(private val sizeLimit: Int) {
|
||||
class TimeStats(private val sizeLimit: Int) {
|
||||
|
||||
private val _maxNTimes: PriorityQueue<TimeNano> = PriorityQueue()
|
||||
private var _count: Long? = null
|
||||
+6
-6
@@ -3,14 +3,14 @@ package com.intellij.util.indexing
|
||||
|
||||
import com.intellij.testFramework.assertions.Assertions.assertThat
|
||||
import com.intellij.testFramework.assertions.Assertions.assertThatThrownBy
|
||||
import com.intellij.util.indexing.diagnostic.MaxNTimeBucket
|
||||
import com.intellij.util.indexing.diagnostic.TimeStats
|
||||
import org.junit.Test
|
||||
import kotlin.random.Random
|
||||
|
||||
class MaxNTimeBucketTest {
|
||||
class TimeStatsTest {
|
||||
@Test
|
||||
fun `empty bucket`() {
|
||||
val bucket = MaxNTimeBucket(1)
|
||||
val bucket = TimeStats(1)
|
||||
assertThat(bucket.isEmpty)
|
||||
assertThatThrownBy { bucket.minTime }
|
||||
assertThatThrownBy { bucket.maxTime }
|
||||
@@ -20,7 +20,7 @@ class MaxNTimeBucketTest {
|
||||
|
||||
@Test
|
||||
fun `one time`() {
|
||||
val bucket = MaxNTimeBucket(1)
|
||||
val bucket = TimeStats(1)
|
||||
val time = 42L
|
||||
bucket.addTime(time)
|
||||
assertThat(!bucket.isEmpty)
|
||||
@@ -32,7 +32,7 @@ class MaxNTimeBucketTest {
|
||||
|
||||
@Test
|
||||
fun `two times`() {
|
||||
val bucket = MaxNTimeBucket(2)
|
||||
val bucket = TimeStats(2)
|
||||
val one = 10L
|
||||
val two = 20L
|
||||
bucket.addTime(one)
|
||||
@@ -48,7 +48,7 @@ class MaxNTimeBucketTest {
|
||||
fun limit() {
|
||||
val numberOfTimes = 1000
|
||||
val bucketSize = 10
|
||||
val bucket = MaxNTimeBucket(bucketSize)
|
||||
val bucket = TimeStats(bucketSize)
|
||||
val times = arrayListOf<Long>()
|
||||
repeat(numberOfTimes) {
|
||||
val time = Random.nextLong()
|
||||
Reference in New Issue
Block a user