Is there a way to see how much time the compiler s...
# compiler
w
Is there a way to see how much time the compiler spends on each source file? I have a very large module I would like to break up and this information would be helpful in prioritizing which classes to move out. Doesn't seem like kotlin build reports offer this information edit: these are all kotlin JVM/android modules
d
There is no such metric. It's problematic to make one because of two reasons: 1. During analysis compiler might jump between files if it requires some information from the other file which is not resolved yet
Copy code
// FILE: a.kt
fun foo() = bar().inc()
fun baz() {}

// FILE: b.kt
fun bar() = 1 + 1
Here we start analysis from file
a.kt
, but when we enter the body of
fun foo
we need to jump to file
b.kt
and analyse
fun bar
first, otherwise it would be impossible to resolve
.inc()
call on
bar()
receiver. 2. There are some computations not stored directly inside the tree (which represent the code), but in some additional services. These computations are usually lazy (computed only when there is an actual reason for that) and cached. The good example of such computation is deserialization of dependencies: when there is a reference to some class from dependencies (e.g. to
ArrayList
from stdlib) the compiler need to scan the classpath for that class, read its metadata from .class file and convert it to the object which is used by the compiler. This operation is quite heavy (e.g. it involves IO), so we want to do it only once and cache the result for further invocations. This caching means, that the time spent on analysis of each file will depend on the order in which files were analyzed (and subtract the time of such computations from the total time of file analysis is quite problematic).
thank you color 1