summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-05-12 10:34:04 +0200
committerDave Davenport <qball@gmpclient.org>2020-05-12 10:34:04 +0200
commit7575c947882d89450201c7e8addcdae5a6a0e47f (patch)
tree3fefa698eba364c5e2dd6adca37e620826b55714
parent7d5bf35f3695408cfdf62f0d62f33f73dad37c94 (diff)
Add some ui benchmark codefbcomplete
-rw-r--r--config/config.c4
-rw-r--r--include/settings.h3
-rw-r--r--source/rofi.c3
-rw-r--r--source/view.c43
4 files changed, 51 insertions, 2 deletions
diff --git a/config/config.c b/config/config.c
index 62adab5d..fe8fcc42 100644
--- a/config/config.c
+++ b/config/config.c
@@ -161,5 +161,7 @@ Settings config = {
.cache_dir = NULL,
.window_thumbnail = FALSE,
.drun_use_desktop_cache = FALSE,
- .drun_reload_desktop_cache = FALSE
+ .drun_reload_desktop_cache = FALSE,
+ /** Benchmarks */
+ .benchmark_ui = FALSE
};
diff --git a/include/settings.h b/include/settings.h
index b1f35e33..7c57080d 100644
--- a/include/settings.h
+++ b/include/settings.h
@@ -196,6 +196,9 @@ typedef struct
/** drun cache */
gboolean drun_use_desktop_cache;
gboolean drun_reload_desktop_cache;
+
+ /** Benchmark */
+ gboolean benchmark_ui;
} Settings;
/** Global Settings structure. */
extern Settings config;
diff --git a/source/rofi.c b/source/rofi.c
index adafeb9d..a4f73633 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -1105,6 +1105,9 @@ int main ( int argc, char *argv[] )
if ( find_arg_uint ( "-record-screenshots", &interval ) ) {
g_timeout_add ( 1000 / (double) interval, record, NULL );
}
+ if ( find_arg ( "-benchmark-ui" ) >= 0 ) {
+ config.benchmark_ui = TRUE;
+ }
rofi_view_workers_initialize ();
rofi_icon_fetcher_init ( );
diff --git a/source/view.c b/source/view.c
index 1a808d54..993c4b97 100644
--- a/source/view.c
+++ b/source/view.c
@@ -223,6 +223,47 @@ void rofi_capture_screenshot ( void )
g_date_time_unref ( now );
}
+
+/**
+ * Code used for benchmarking drawing the gui, this will keep updating the UI as fast as possible.
+ */
+gboolean do_bench = TRUE;
+struct {
+ GTimer *time;
+ uint64_t draws;
+ double last_ts;
+ double min;
+} BenchMark = {
+ .time = NULL,
+ .draws = 0,
+ .last_ts = 0.0,
+ .min = G_MAXDOUBLE
+};
+
+static gboolean bench_update ( void )
+{
+ if ( !config.benchmark_ui ) {
+ return FALSE;
+ }
+ BenchMark.draws++;
+ if ( BenchMark.time == NULL ) {
+ BenchMark.time = g_timer_new();
+ }
+
+ if ( (BenchMark.draws & 1023) == 0 ){
+ double ts = g_timer_elapsed(BenchMark.time, NULL);
+ double fps = 1024/(ts-BenchMark.last_ts);
+
+ if ( fps < BenchMark.min ) {
+ BenchMark.min = fps;
+ }
+ printf("current: %.2f fps, avg: %.2f fps, min: %.2f fps, %lu draws\r\n", fps, BenchMark.draws/ts, BenchMark.min, BenchMark.draws);
+
+ BenchMark.last_ts = ts;
+ }
+ return TRUE;
+}
+
static gboolean rofi_view_repaint ( G_GNUC_UNUSED void * data )
{
if ( current_active_menu ) {
@@ -238,7 +279,7 @@ static gboolean rofi_view_repaint ( G_GNUC_UNUSED void * data )
TICK_N ( "flush" );
CacheState.repaint_source = 0;
}
- return G_SOURCE_REMOVE;
+ return (bench_update () == TRUE )? G_SOURCE_CONTINUE:G_SOURCE_REMOVE;
}
static void rofi_view_update_prompt ( RofiViewState *state )