Add a Ziran benchmark (tests/desktop_benchmark*.zi; make desktop-benchmark and desktop-benchmark-build) for moving the Linux desktop build off raylib. It drives the app through the Kryon test driver on a private Xvfb with a seeded profile and no audio device: screen switches, a 240-item list scrolled by wheel, a modal, a floating practice window, then 30 s idle. It reports time to first frame, frame rate and frame cost, idle CPU, resident memory, build times, generated C, executable size and libraries, each as a median over runs with its range. Under APP_PROFILE the app now logs when each host frame begins and the process CPU time then, so the benchmark can take per-frame intervals. plans/2026-11-15-breeze-desktop-without-raylib.md records the method, the raylib baseline measured with the installed build, and the call-site map for the port.
90 lines
3.1 KiB
Ziran
90 lines
3.1 KiB
Ziran
// The profile every benchmark run starts from. The app creates it once;
|
|
// SQLite then marks first-run guides and setup as done, turns off update
|
|
// checks and adds one list long enough to scroll. Each run copies it.
|
|
#import "file_tree_linux"
|
|
#import "text_tools"
|
|
#import "vec"
|
|
|
|
#scope_file
|
|
sqlite :: #system_library "sqlite3";
|
|
SqliteOpen :: (path: *u8, database: **void) -> s32 #foreign sqlite "sqlite3_open";
|
|
SqliteExec :: (database: *void, sql: *u8, callback: *void, argument: *void,
|
|
error: **u8) -> s32 #foreign sqlite "sqlite3_exec";
|
|
SqliteClose :: (database: *void) -> s32 #foreign sqlite "sqlite3_close";
|
|
|
|
CText :: (text: string) -> Vec(u8) {
|
|
bytes: Vec(u8)
|
|
for index: cast(s64)0..text.count - 1 {
|
|
VecPush(bytes, text[index])
|
|
}
|
|
VecPush(bytes, 0)
|
|
return bytes
|
|
}
|
|
|
|
// Settings that let the app open straight to its screens: no language,
|
|
// apps or audio setup, no guides, no update checks or downloads.
|
|
SETTINGS :: #string SQL
|
|
language=en
|
|
language_system=0
|
|
language_setup_done=1
|
|
apps_setup_done=1
|
|
enabled_apps=31
|
|
lumi_introduced=1
|
|
package_updates_allowed=0
|
|
apps_last_update_check=1900000000
|
|
tutorial_seen=1
|
|
habits_guide_seen=1
|
|
lumi_guides_seen=127
|
|
launcher_guide_seen=1
|
|
ui_scale=10
|
|
navigation_placement=1
|
|
navigation_collapsed=0
|
|
SQL
|
|
|
|
LONG_LIST_ITEMS :: 240
|
|
#scope_export
|
|
|
|
BENCHMARK_LIST_TITLE :: "Benchmark list"
|
|
|
|
SeedSql :: () -> Text {
|
|
sql: Vec(u8)
|
|
lines := TextLines(SETTINGS)
|
|
for index: cast(s64)0..lines.count - 1 {
|
|
line := lines[index]
|
|
equals := TextFind(line, "=")
|
|
if equals > 0 {
|
|
BuilderPrint(*sql, "INSERT INTO settings(user_id,key,value,updated_at) ")
|
|
BuilderPrint(*sql, "SELECT id,'%','%',1 FROM users WHERE kind='local' ",
|
|
line[:equals], line[equals + 1:])
|
|
BuilderPrint(*sql, "ON CONFLICT(user_id,key) DO UPDATE SET value=excluded.value;\n")
|
|
}
|
|
}
|
|
BuilderPrint(*sql, "INSERT INTO elist_lists(id,user_id,title,sort_order,updated_at) ")
|
|
BuilderPrint(*sql, "SELECT 'benchmark-list',id,'%',0,1 FROM users WHERE kind='local';\n",
|
|
BENCHMARK_LIST_TITLE)
|
|
BuilderPrint(*sql, "WITH RECURSIVE n(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM n WHERE i<%) ",
|
|
LONG_LIST_ITEMS)
|
|
BuilderPrint(*sql, "INSERT INTO elist_items(id,user_id,list_id,title,sort_order,updated_at) ")
|
|
BuilderPrint(*sql, "SELECT 'benchmark-item-'||i,(SELECT id FROM users WHERE kind='local'),")
|
|
BuilderPrint(*sql, "'benchmark-list','Benchmark item '||i,i,1 FROM n;\n")
|
|
BuilderPrint(*sql, "PRAGMA wal_checkpoint(TRUNCATE);\n")
|
|
return BuilderFinish(sql)
|
|
}
|
|
|
|
// Applies the benchmark's settings and list to the app's database in
|
|
// PROFILE, which the app created and has closed.
|
|
SeedProfile :: (profile: string) -> bool {
|
|
path := JoinPath(profile, "inbe.db")
|
|
path_bytes := CText(path)
|
|
database: *void
|
|
if SqliteOpen(*path_bytes[0], *database) != 0 {
|
|
unused SqliteClose(database)
|
|
return false
|
|
}
|
|
sql := SeedSql()
|
|
sql_bytes := CText(sql)
|
|
ok := SqliteExec(database, *sql_bytes[0], null, null, null) == 0
|
|
unused SqliteClose(database)
|
|
return ok
|
|
}
|