[gtk: 5/14] Convert all profiler times from nsec to usec
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 5/14] Convert all profiler times from nsec to usec
- Date: Wed, 12 Feb 2020 14:32:51 +0000 (UTC)
commit cc643df88b541b7505885ecff02c8576decf6bbd
Author: Alexander Larsson <alexl redhat com>
Date: Wed Feb 12 10:44:17 2020 +0100
Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).
Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
gdk/gdkdrawcontext.c | 2 +-
gdk/gdkframeclock.c | 18 +++++++++---------
gdk/gdkframeclockidle.c | 6 +++---
gdk/gdkprofiler.c | 12 ++++++------
gdk/gdksurface.c | 4 ++--
gdk/wayland/gdkdisplay-wayland.c | 2 +-
gdk/wayland/gdkglcontext-wayland.c | 2 +-
gdk/wayland/gdksurface-wayland.c | 8 ++++----
gsk/gl/gskglprofiler.c | 2 +-
gsk/gl/gskglrenderer.c | 2 +-
gsk/gskprofiler.c | 17 ++++++++---------
gtk/gtkapplication.c | 4 ++--
gtk/gtkbuilderparser.c | 2 +-
gtk/gtkcssnode.c | 6 +++---
gtk/gtkcssprovider.c | 4 ++--
gtk/gtkemojichooser.c | 4 ++--
gtk/gtkicontheme.c | 5 +++--
gtk/gtkwidget.c | 4 ++--
gtk/gtkwindow.c | 2 +-
19 files changed, 53 insertions(+), 53 deletions(-)
---
diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c
index 93f85528e6..5c25d87407 100644
--- a/gdk/gdkdrawcontext.c
+++ b/gdk/gdkdrawcontext.c
@@ -385,7 +385,7 @@ gdk_draw_context_end_frame (GdkDrawContext *context)
#ifdef G_ENABLE_DEBUG
if (gdk_profiler_is_running ())
gdk_profiler_set_int_counter (pixels_counter,
- g_get_monotonic_time () * 1000,
+ g_get_monotonic_time (),
region_get_pixels (priv->frame_region));
#endif
diff --git a/gdk/gdkframeclock.c b/gdk/gdkframeclock.c
index 272edbe4f6..de5deb887a 100644
--- a/gdk/gdkframeclock.c
+++ b/gdk/gdkframeclock.c
@@ -654,7 +654,7 @@ _gdk_frame_clock_emit_flush_events (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "flush-events");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "flush-events");
}
}
@@ -668,7 +668,7 @@ _gdk_frame_clock_emit_before_paint (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "before-paint");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "before-paint");
}
}
@@ -682,7 +682,7 @@ _gdk_frame_clock_emit_update (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "update");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "update");
}
}
@@ -696,7 +696,7 @@ _gdk_frame_clock_emit_layout (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "layout");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "layout");
}
}
@@ -710,7 +710,7 @@ _gdk_frame_clock_emit_paint (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "paint");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "paint");
}
}
@@ -724,7 +724,7 @@ _gdk_frame_clock_emit_after_paint (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "after-paint");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "after-paint");
}
}
@@ -738,7 +738,7 @@ _gdk_frame_clock_emit_resume_events (GdkFrameClock *frame_clock)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "frameclock", "resume-events");
+ gdk_profiler_add_mark (before, (after - before), "frameclock", "resume-events");
}
}
@@ -818,9 +818,9 @@ _gdk_frame_clock_add_timings_to_profiler (GdkFrameClock *clock,
{
if (timings->presentation_time != 0)
{
- gdk_profiler_add_mark (timings->presentation_time * 1000, 0, "frameclock", "presentation");
+ gdk_profiler_add_mark (timings->presentation_time, 0, "frameclock", "presentation");
gdk_profiler_set_counter (fps_counter,
- timings->presentation_time * 1000,
+ timings->presentation_time,
frame_clock_get_fps (clock));
}
}
diff --git a/gdk/gdkframeclockidle.c b/gdk/gdkframeclockidle.c
index 29cd57975f..b350924ce2 100644
--- a/gdk/gdkframeclockidle.c
+++ b/gdk/gdkframeclockidle.c
@@ -502,7 +502,7 @@ gdk_frame_clock_paint_idle (void *data)
priv->sleep_serial = get_sleep_serial ();
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "frameclock",
"paint_idle");
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "frameclock", "paint_idle");
return FALSE;
}
@@ -599,8 +599,8 @@ gdk_frame_clock_idle_thaw (GdkFrameClock *clock)
if (priv->freeze_time != 0)
{
gint64 thaw_time = g_get_monotonic_time ();
- gdk_profiler_add_mark (priv->freeze_time * 1000,
- (thaw_time - priv->freeze_time) * 1000,
+ gdk_profiler_add_mark (priv->freeze_time,
+ (thaw_time - priv->freeze_time),
"frameclock freeze", "");
priv->freeze_time = 0;
}
diff --git a/gdk/gdkprofiler.c b/gdk/gdkprofiler.c
index d7eeaa1d52..81288be173 100644
--- a/gdk/gdkprofiler.c
+++ b/gdk/gdkprofiler.c
@@ -94,9 +94,9 @@ gdk_profiler_add_mark (gint64 start,
return;
sysprof_capture_writer_add_mark (writer,
- start,
+ start * 1000L,
-1, getpid (),
- duration,
+ duration * 1000L,
"gtk", name, message);
}
@@ -118,9 +118,9 @@ gdk_profiler_add_markf (gint64 start,
va_end (args);
sysprof_capture_writer_add_mark (writer,
- start,
+ start * 1000L,
-1, getpid (),
- duration,
+ duration * 1000L,
"gtk", name, message);
g_free (message);
}
@@ -178,7 +178,7 @@ gdk_profiler_set_counter (guint id,
value.vdbl = val;
sysprof_capture_writer_set_counters (writer,
- time,
+ time * 1000L,
-1, getpid (),
&id, &value, 1);
}
@@ -195,7 +195,7 @@ gdk_profiler_set_int_counter (guint id,
value.v64 = val;
sysprof_capture_writer_set_counters (writer,
- time,
+ time * 1000L,
-1, getpid (),
&id, &value, 1);
}
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 9725e03bc6..9c95736aed 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -4103,9 +4103,9 @@ add_event_mark (GdkEvent *event,
}
if (kind != NULL && message != NULL)
- gdk_profiler_add_markf (time * 1000L, duration * 1000L, "event", "%s %s", kind, message);
+ gdk_profiler_add_markf (time, duration, "event", "%s %s", kind, message);
else
- gdk_profiler_add_mark (time * 1000L, duration * 1000L, "event", message ? message : kind);
+ gdk_profiler_add_mark (time, duration, "event", message ? message : kind);
g_free (message);
}
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 10c4445c36..59ffdea73c 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -1155,7 +1155,7 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
if (gdk_profiler_is_running ())
{
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "wayland", "load
cursor theme");
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "wayland", "load cursor theme");
}
}
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index ec647c7764..0b9dbb5da7 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -239,7 +239,7 @@ gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
gdk_wayland_surface_sync (surface);
gdk_wayland_surface_request_frame (surface);
- gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "swap buffers");
+ gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "swap buffers");
if (display_wayland->have_egl_swap_buffers_with_damage)
{
int i, j, n_rects = cairo_region_num_rectangles (painted);
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 4850bafd8a..58d94881a1 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -357,7 +357,7 @@ frame_callback (void *data,
GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
GdkFrameTimings *timings;
- gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "frame event");
+ gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "frame event");
GDK_DISPLAY_NOTE (GDK_DISPLAY (display_wayland), EVENTS, g_message ("frame %p", surface));
wl_callback_destroy (callback);
@@ -478,7 +478,7 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
* before we need to stage any changes, then we can take it back and
* use it again.
*/
- gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
+ gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
impl->pending_commit = FALSE;
@@ -1510,7 +1510,7 @@ gdk_wayland_surface_create_xdg_toplevel (GdkSurface *surface)
if (impl->hint == GDK_SURFACE_TYPE_HINT_DIALOG)
_gdk_wayland_screen_add_orphan_dialog (surface);
- gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
+ gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
}
@@ -2305,7 +2305,7 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface *surface,
}
}
- gdk_profiler_add_mark (g_get_monotonic_time () * 1000, 0, "wayland", "surface commit");
+ gdk_profiler_add_mark (g_get_monotonic_time (), 0, "wayland", "surface commit");
wl_surface_commit (impl->display_server.wl_surface);
impl->popup_parent = parent;
diff --git a/gsk/gl/gskglprofiler.c b/gsk/gl/gskglprofiler.c
index 0d58ee89d1..95f5a794a5 100644
--- a/gsk/gl/gskglprofiler.c
+++ b/gsk/gl/gskglprofiler.c
@@ -171,5 +171,5 @@ gsk_gl_profiler_end_gpu_region (GskGLProfiler *profiler)
else
elapsed = 0;
- return elapsed;
+ return elapsed / 1000; /* Convert to usec to match other profiler APIs */
}
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index cb88c8ca71..b1556f831f 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -2858,7 +2858,7 @@ gsk_gl_renderer_realize (GskRenderer *renderer,
gsk_gl_shadow_cache_init (&self->shadow_cache);
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "gl renderer realize",
NULL);
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "gl renderer realize", NULL);
return TRUE;
}
diff --git a/gsk/gskprofiler.c b/gsk/gskprofiler.c
index a18362a6c8..e9ef91af93 100644
--- a/gsk/gskprofiler.c
+++ b/gsk/gskprofiler.c
@@ -262,7 +262,7 @@ gsk_profiler_timer_begin (GskProfiler *profiler,
return;
timer->in_flight = TRUE;
- timer->start_time = g_get_monotonic_time () * 1000;
+ timer->start_time = g_get_monotonic_time ();
}
gint64
@@ -289,7 +289,7 @@ gsk_profiler_timer_end (GskProfiler *profiler,
return 0;
}
- diff = (g_get_monotonic_time () * 1000) - timer->start_time;
+ diff = g_get_monotonic_time () - timer->start_time;
timer->in_flight = FALSE;
timer->value += diff;
@@ -360,7 +360,7 @@ gsk_profiler_timer_get (GskProfiler *profiler,
}
if (timer->invert)
- return (gint64) (1000000000.0 / (double) timer->value);
+ return (gint64) (1000000.0 / (double) timer->value);
return timer->value;
}
@@ -437,7 +437,7 @@ gsk_profiler_push_samples (GskProfiler *profiler)
s->id = timer->id;
if (timer->invert)
- s->value = (gint64) (1000000000.0 / (double) timer->value);
+ s->value = (gint64) (1000000.0 / (double) timer->value);
else
s->value = timer->value;
}
@@ -506,20 +506,19 @@ gsk_profiler_append_timers (GskProfiler *profiler,
{
NamedTimer *timer = value_p;
const char *unit = timer->invert ? "" : "usec";
- double scale = timer->invert ? 1.0 : 1000.0;
g_string_append_printf (buffer, "%s (%s): %.2f",
timer->description,
unit,
- (double) timer->value / scale);
+ (double) timer->value);
if (timer->n_samples > 1)
{
timer->avg_value = timer->avg_value / timer->n_samples;
g_string_append_printf (buffer, " Min: %.2f Avg: %.2f Max: %.2f (%" G_GINT64_FORMAT " samples)",
- (double) timer->min_value / scale,
- (double) timer->avg_value / scale,
- (double) timer->max_value / scale,
+ (double) timer->min_value,
+ (double) timer->avg_value,
+ (double) timer->max_value,
timer->n_samples);
}
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index a60feee9e5..6885c4e44f 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -307,7 +307,7 @@ gtk_application_startup (GApplication *g_application)
before2 = g_get_monotonic_time ();
gtk_init ();
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (before2 * 1000, (g_get_monotonic_time () - before2) * 1000, "gtk init", NULL);
+ gdk_profiler_add_mark (before2, (g_get_monotonic_time () - before2), "gtk init", NULL);
priv->impl = gtk_application_impl_new (application, gdk_display_get_default ());
gtk_application_impl_startup (priv->impl, priv->register_session);
@@ -315,7 +315,7 @@ gtk_application_startup (GApplication *g_application)
gtk_application_load_resources (application);
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "gtk application
startup", NULL);
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "gtk application startup", NULL);
}
static void
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 7b781c17d1..6247f53f9d 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -1625,5 +1625,5 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
/* restore the original domain */
gtk_builder_set_translation_domain (builder, domain);
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "builder load", filename);
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "builder load", filename);
}
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 4932447955..03fd29a795 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -1354,9 +1354,9 @@ gtk_css_node_validate (GtkCssNode *cssnode)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "css validation", "");
- gdk_profiler_set_int_counter (invalidated_nodes_counter, after * 1000, invalidated_nodes);
- gdk_profiler_set_int_counter (created_styles_counter, after * 1000, created_styles);
+ gdk_profiler_add_mark (before, (after - before), "css validation", "");
+ gdk_profiler_set_int_counter (invalidated_nodes_counter, after, invalidated_nodes);
+ gdk_profiler_set_int_counter (created_styles_counter, after, created_styles);
invalidated_nodes = 0;
created_styles = 0;
}
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 9d26e7172c..986d38a40d 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1010,7 +1010,7 @@ gtk_css_provider_postprocess (GtkCssProvider *css_provider)
#endif
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "create selector tree",
NULL);
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "create selector tree", NULL);
}
static void
@@ -1071,7 +1071,7 @@ gtk_css_provider_load_internal (GtkCssProvider *self,
if (gdk_profiler_is_running ())
{
char *uri = g_file_get_uri (file);
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "theme load", uri);
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "theme load", uri);
g_free (uri);
}
}
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index f546b9f3a3..a82eaf9e2e 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -466,7 +466,7 @@ populate_emoji_chooser (gpointer data)
if (now > start + 8000)
{
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (start * 1000, (now - start) * 1000, "emojichooser", "populate");
+ gdk_profiler_add_mark (start, (now - start), "emojichooser", "populate");
return G_SOURCE_CONTINUE;
}
}
@@ -479,7 +479,7 @@ populate_emoji_chooser (gpointer data)
if (gdk_profiler_is_running ())
{
now = g_get_monotonic_time ();
- gdk_profiler_add_mark (start * 1000, (now - start) * 1000, "emojichooser", "populate (finish)");
+ gdk_profiler_add_mark (start, (now - start), "emojichooser", "populate (finish)");
}
return G_SOURCE_REMOVE;
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index aec4b78b4a..398f5558de 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -1847,7 +1847,7 @@ ensure_valid_themes (GtkIconTheme *self,
load_themes (self);
if (gdk_profiler_is_running ())
- gdk_profiler_add_mark (before * 1000, (g_get_monotonic_time () - before) * 1000, "icon theme load",
self->current_theme);
+ gdk_profiler_add_mark (before, (g_get_monotonic_time () - before), "icon theme load",
self->current_theme);
if (was_valid)
queue_theme_changed (self);
@@ -3606,7 +3606,8 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
g_assert (icon->texture != NULL);
if (gdk_profiler_is_running ())
- gdk_profiler_add_markf (before * 1000, (g_get_monotonic_time () - before) * 1000, in_thread ? "icon
load (thread)" : "icon load" , "%s size %d@%d", icon->filename, icon->desired_size, icon->desired_scale);
+ gdk_profiler_add_markf (before, g_get_monotonic_time () - before, in_thread ? "icon load (thread)" :
"icon load" ,
+ "%s size %d@%d", icon->filename, icon->desired_size, icon->desired_scale);
}
static GdkTexture *
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 70e59ce60a..294a5d6b19 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12196,7 +12196,7 @@ gtk_widget_render (GtkWidget *widget,
if (gdk_profiler_is_running ())
{
after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "widget snapshot", "");
+ gdk_profiler_add_mark (before, (after - before), "widget snapshot", "");
}
if (root != NULL)
@@ -12215,7 +12215,7 @@ gtk_widget_render (GtkWidget *widget,
{
before = after;
after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "widget render", "");
+ gdk_profiler_add_mark (before, (after - before), "widget render", "");
}
}
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c2b8a9fe4e..5f179d0c99 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -6319,7 +6319,7 @@ gtk_window_check_resize (GtkWindow *self)
if (gdk_profiler_is_running ())
{
gint64 after = g_get_monotonic_time ();
- gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "size allocation", "");
+ gdk_profiler_add_mark (before, (after - before), "size allocation", "");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]