summaryrefslogtreecommitdiff
path: root/folks
diff options
context:
space:
mode:
Diffstat (limited to 'folks')
-rw-r--r--folks/backend-store.vala8
-rw-r--r--folks/individual-aggregator.vala4
-rw-r--r--folks/internal.vala49
-rw-r--r--folks/meson.build3
4 files changed, 33 insertions, 31 deletions
diff --git a/folks/backend-store.vala b/folks/backend-store.vala
index e3f97177..11c37ac9 100644
--- a/folks/backend-store.vala
+++ b/folks/backend-store.vala
@@ -276,7 +276,7 @@ public class Folks.BackendStore : Object {
*/
public async void prepare ()
{
- Internal.profiling_start ("preparing BackendStore");
+ var profiling = Internal.profiling_start ("preparing BackendStore");
/* (re-)load the list of disabled backends */
yield this._load_disabled_backend_names ();
@@ -287,7 +287,7 @@ public class Folks.BackendStore : Object {
this.notify_property ("is-prepared");
}
- Internal.profiling_end ("preparing BackendStore");
+ Internal.profiling_end ((owned) profiling);
}
/**
@@ -305,7 +305,7 @@ public class Folks.BackendStore : Object {
{
assert (Module.supported());
- Internal.profiling_start ("loading backends in BackendStore");
+ var profiling = Internal.profiling_start ("loading backends in BackendStore");
yield this.prepare ();
@@ -400,7 +400,7 @@ public class Folks.BackendStore : Object {
yield;
}
- Internal.profiling_end ("loading backends in BackendStore");
+ Internal.profiling_end ((owned) profiling);
}
/* This method is not safe to call multiple times concurrently, since there's
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index fb801001..831507b7 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -695,7 +695,7 @@ public class Folks.IndividualAggregator : Object
*/
public async void prepare () throws GLib.Error
{
- Internal.profiling_start ("preparing IndividualAggregator");
+ var profiling = Internal.profiling_start ("preparing IndividualAggregator");
/* Once this async function returns, all the {@link Backend}s will have
* been prepared (though no {@link PersonaStore}s are guaranteed to be
@@ -751,7 +751,7 @@ public class Folks.IndividualAggregator : Object
this._prepare_pending = false;
}
- Internal.profiling_end ("preparing IndividualAggregator");
+ Internal.profiling_end ((owned) profiling);
}
/**
diff --git a/folks/internal.vala b/folks/internal.vala
index 1d4030f2..35ec807a 100644
--- a/folks/internal.vala
+++ b/folks/internal.vala
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Collabora Ltd.
+ * Copyright 2011,2023 Collabora Ltd.
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -16,6 +16,7 @@
*
* Authors:
* Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
+ * Corentin Noël <corentin.noel@collabora.com>
*/
using GLib;
@@ -38,17 +39,6 @@ namespace Folks.Internal
return true;
}
-#if ENABLE_PROFILING
- /* See: http://people.gnome.org/~federico/news-2006-03.html#timeline-tools */
- [PrintfFormat]
- private static void profiling_markv (string format, va_list args)
- {
- var formatted = format.vprintf (args);
- var str = "MARK: %s-%p: %s".printf (Environment.get_prgname (), Thread.self<void> (), formatted);
- access (str, F_OK);
- }
-#endif
-
/**
* Emit a profiling point.
*
@@ -57,14 +47,27 @@ namespace Folks.Internal
*
* @param format printf-style message format
* @param ... message arguments
- * @since 0.7.2
*/
[PrintfFormat]
- public static void profiling_point (string format, ...)
+ public inline void profiling_point (string format, ...)
{
#if ENABLE_PROFILING
var args = va_list ();
- Internal.profiling_markv (format, args);
+ Sysprof.Collector.log (0, "folks", format.vprintf(args));
+#endif
+ }
+
+ [Compact]
+ public class ProfileBlock
+ {
+#if ENABLE_PROFILING
+ internal string name;
+ internal int64 start;
+
+ internal ProfileBlock (owned string name) {
+ this.name = (owned) name;
+ this.start = Sysprof.CAPTURE_CURRENT_TIME;
+ }
#endif
}
@@ -79,13 +82,14 @@ namespace Folks.Internal
*
* @param format printf-style message format
* @param ... message arguments
- * @since 0.7.2
*/
- public static void profiling_start (string format, ...)
+ public inline ProfileBlock? profiling_start (string format, ...)
{
#if ENABLE_PROFILING
var args = va_list ();
- Internal.profiling_markv ("START: " + format, args);
+ return new ProfileBlock (format.vprintf (args));
+#else
+ return null;
#endif
}
@@ -98,15 +102,12 @@ namespace Folks.Internal
* This is typically used in a pair with {@link Internal.profiling_start} to
* delimit blocks of processing which need timing.
*
- * @param format printf-style message format
- * @param ... message arguments
- * @since 0.7.2
+ * @param block the ProfileBlock given by profiling_start
*/
- public static void profiling_end (string format, ...)
+ public inline void profiling_end (owned ProfileBlock? block)
{
#if ENABLE_PROFILING
- var args = va_list ();
- Internal.profiling_markv ("END: " + format, args);
+ Sysprof.Collector.mark (block.start, Sysprof.CAPTURE_CURRENT_TIME - block.start, "folks", block.name);
#endif
}
}
diff --git a/folks/meson.build b/folks/meson.build
index 821a3099..b86f3cc7 100644
--- a/folks/meson.build
+++ b/folks/meson.build
@@ -16,7 +16,8 @@ libfolks_internal_deps = [
libfolks_internal_vala_flags = []
if get_option('profiling')
- libfolks_internal_vala_flags += '-DENABLE_PROFILING'
+ libfolks_internal_vala_flags += '--define=ENABLE_PROFILING'
+ libfolks_internal_deps += sysprof_dep
endif
libfolks_internal = static_library('folks-internal',