Skip to content

Commit 33a163c

Browse files
committed
merge: timing marks
2 parents f62a432 + edb02c3 commit 33a163c

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎android/sample/src/main/java/io/github/dingyi222666/luaparser/sample/MainActivity.kt‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,24 @@ class MainActivity : AppCompatActivity(), FileBrowserFragment.Listener {
161161
diagnosticsBar.setOnClickListener { jumpToFirstProblem() }
162162

163163
lifecycleScope.launch {
164+
val t0 = System.currentTimeMillis()
165+
fun mark(phase: String) {
166+
val total = System.currentTimeMillis() - t0
167+
Log.i("PerfTiming", "$phase at +${total}ms")
168+
runOnUiThread {
169+
diagSummary.text = getString(R.string.diag_opening, phase, total.toInt())
170+
}
171+
}
172+
mark("copying workspace")
164173
prepareWorkspace()
165-
connectToLanguageServer()
166-
// Open the corpus entry point through the SAME flow the file
167-
// browser uses: attach bridge -> load text -> connect -> didOpen.
174+
mark("workspace ready")
175+
// Second-level open: openFile shows the text immediately and runs
176+
// the LSP bridge attach + connect on IO — the editor is usable
177+
// while the language server warms up in the background.
178+
mark("editor text loading")
168179
openFile(sampleFile.toRelativeString(projectDir))
180+
mark("open complete")
181+
Log.i("PerfTiming", "TOTAL open at +${System.currentTimeMillis() - t0}ms (lsp continues async)")
169182
}
170183
}
171184

‎android/sample/src/main/res/values/strings.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
<string name="msg_formatted">Formatted (unsaved — use Save to persist)</string>
2626
<string name="msg_no_formatting">No formatting edits returned</string>
2727
<string name="msg_not_connected">Language server is not connected</string>
28+
<string name="diag_opening">%1$s + %2$dms</string>
2829
</resources>

0 commit comments

Comments
 (0)