<lambda>null1 package leakcanary
2 
3 import android.os.SystemClock
4 import androidx.test.platform.app.InstrumentationRegistry
5 import org.junit.Test
6 import shark.Hprof
7 import shark.HprofHeapGraph
8 import shark.SharkLog
9 import java.io.File
10 import java.io.FileOutputStream
11 
12 class IndexingTest {
13 
14   @Test fun indexHprof() {
15     val instrumentation = InstrumentationRegistry.getInstrumentation()
16     val context = instrumentation.targetContext
17 
18     val heapDumpFile = File(context.filesDir, "AnalysisDurationTest.hprof")
19     context.assets.open("large-dump.hprof").copyTo(FileOutputStream(heapDumpFile))
20 
21     Hprof.open(heapDumpFile).use { hprof ->
22       SharkLog.d { "Start indexing" }
23       val before = SystemClock.uptimeMillis()
24       HprofHeapGraph.indexHprof(hprof)
25       val durationMs = (SystemClock.uptimeMillis() - before)
26       SharkLog.d { "Indexing took $durationMs ms" }
27     }
28   }
29 }
30 
31