Skip to content

Startup time

Latest
Compare
Choose a tag to compare
@andycate andycate released this 08 Mar 03:48
· 6 commits to master since this release
79102e1

This update cuts the startup time by 300%. The cause of the long startup time was the use of reflection to initialize class properties. As reflection is an expensive set of operations, the better way to approach this issue is with the use of the provideDelegate function inside DashboardDelegate.

To use this update, instead of calling DashboardVar.initClassProps(this::class), just make sure that the classes with dashboard properties get initialized. A simple example:

object Constants {
    fun initProps() {
        println("init Constants")
        First.initProps()
        Nested.initProps()
    }
    public var PROP by DashboardVar(0.0)
    object First {
        fun initProps() {
            println("init First")
        }
        public var PROP by DashboardVar(1.0)
    }
    object Nested {
        fun initProps() {
            println("init Nested")
            Inner.initProps()
        }
        public var PROP by DashboardVar(2.0)
        object Inner {
            fun initProps() {
                println("init Inner")
            }
            public var PROP by DashboardVar(3.0)
        }
    }
}