Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

chore: add startup timing diagnostics for #270

t8y2ecb878315c2a
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index d8c45c82f1..cef320a880 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -12,6 +12,8 @@ use tauri::{Manager, RunEvent};
pub fn run() {
rustls::crypto::aws_lc_rs::default_provider().install_default().expect("Failed to install rustls crypto provider");
+ let startup_begin = Instant::now();
+
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
@@ -19,7 +21,10 @@ pub fn run() {
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_window_state::Builder::default().build())
- .setup(|app| {
+ .setup(move |app| {
+ let setup_start = Instant::now();
+ eprintln!("[STARTUP] plugins registered in {:?}", startup_begin.elapsed());
+
if cfg!(debug_assertions) {
app.handle().plugin(tauri_plugin_log::Builder::default().level(log::LevelFilter::Info).build())?;
}
@@ -29,17 +34,23 @@ pub fn run() {
std::fs::create_dir_all(&data_dir).expect("Failed to create data dir");
let db_path = data_dir.join("dbx.db");
+ let t = Instant::now();
let storage = tauri::async_runtime::block_on(async {
let s = Storage::open(&db_path).await.expect("Failed to open storage");
+ eprintln!("[STARTUP] Storage::open in {:?}", t.elapsed());
+ let t2 = Instant::now();
s.migrate_from_json(&data_dir).await.expect("Failed to migrate JSON data");
+ eprintln!("[STARTUP] migrate_from_json in {:?}", t2.elapsed());
s
});
+ eprintln!("[STARTUP] storage ready in {:?}", t.elapsed());
let state = Arc::new(AppState::new_with_plugin_dir(storage, data_dir.join("plugins")));
app.manage(state.clone());
let app_handle = app.handle().clone();
commands::mcp_bridge::start(app_handle, state);
+ eprintln!("[STARTUP] setup complete in {:?} (total {:?})", setup_start.elapsed(), startup_begin.elapsed());
#[cfg(not(target_os = "macos"))]
{
diff --git a/src/App.vue b/src/App.vue
index f0bb770a80..e2d4d04ef8 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -466,10 +466,16 @@ function onLoginSuccess() {
}
function initApp() {
+ const t0 = performance.now();
+ console.log("[STARTUP] initApp begin");
savedSqlStore
.initFromStorage()
- .then(() => connectionStore.initFromDisk())
.then(() => {
+ console.log(`[STARTUP] savedSqlStore.initFromStorage: ${(performance.now() - t0).toFixed(0)}ms`);
+ return connectionStore.initFromDisk();
+ })
+ .then(() => {
+ console.log(`[STARTUP] connectionStore.initFromDisk: ${(performance.now() - t0).toFixed(0)}ms`);
reconnectRestoredTabs();
})
.catch((e: any) => {
@@ -501,6 +507,8 @@ function handleContextMenu(e: MouseEvent) {
}
onMounted(async () => {
+ console.log("[STARTUP] onMounted begin");
+ const mountStart = performance.now();
applyTheme();
window.addEventListener("keydown", handleKeydown, true);
if (isDesktop) {
@@ -541,6 +549,7 @@ onMounted(async () => {
})
.catch(() => {});
setupTauriListeners();
+ console.log(`[STARTUP] onMounted sync done: ${(performance.now() - mountStart).toFixed(0)}ms`);
});
onUnmounted(() => {