[glib/3v1n0/allocation-benchmarks] allocator-tests: Add some machine-readable output




commit da5066f606f9f03c102bdcb762da4d6675ceed3d
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Jul 7 17:40:15 2022 +0200

    allocator-tests: Add some machine-readable output

 tests/allocators-tests.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/tests/allocators-tests.c b/tests/allocators-tests.c
index eee9c20950..7702510bab 100644
--- a/tests/allocators-tests.c
+++ b/tests/allocators-tests.c
@@ -40,6 +40,13 @@
 #define instance_free(s, p) g_slice_free1 ((s), (p))
 #endif
 
+static void
+csv_report (const char *allocator, gint iterations, gdouble time_elapsed)
+{
+  g_test_message ("CSV: %s/%s/%d,%f",
+                  g_test_get_path (), allocator, iterations, time_elapsed);
+}
+
 #define allocate_and_free_many(type, type_size, allocator, N) \
   {                                                           \
     guint i;                                                  \
@@ -64,6 +71,7 @@
                              "Allocated and free'd %u instances of %s "              \
                              "(size: %" G_GSIZE_FORMAT " using %s in %6.5f seconds", \
                              N, #type, (gsize) type_size, #allocator, time_elapsed); \
+    csv_report (#allocator, N, time_elapsed);                                        \
   }
 
 #define test_alloc_many_and_free(type, type_size, allocator, N)                      \
@@ -85,6 +93,7 @@
                              "Allocated %u instances of %s (size: %" G_GSIZE_FORMAT  \
                              ") using %s in %6.5f seconds",                          \
                              N, #type, (gsize) type_size, #allocator, time_elapsed); \
+    csv_report (#allocator, N, time_elapsed);                                        \
                                                                                      \
     g_test_timer_start ();                                                           \
                                                                                      \
@@ -97,10 +106,14 @@
     g_test_minimized_result (time_elapsed,                                           \
                              "Free'd %u instances of %s in %6.5f seconds",           \
                              N, #type, time_elapsed);                                \
+    csv_report ("free", N, time_elapsed);                                            \
+                                                                                     \
     g_test_minimized_result (total_time,                                             \
                              "Allocated and Free'd %u instances of %s using %s "     \
                              "in %6.5f seconds",                                     \
                              N, #type, #allocator, total_time);                      \
+                                                                                     \
+    csv_report (#allocator "+free", N, total_time);                                  \
   }
 
 #define test_allocation_simple_type(type)                                                 \
@@ -155,6 +168,7 @@
                              "Allocated and free'd %u instances of mixed types "      \
                              "(step: %s) using %s in %6.5f seconds",                  \
                              N, #max_steps, #allocator, time_elapsed);                \
+    csv_report (#allocator, N, time_elapsed);                                         \
   }
 
 #define test_allocation_mixed_sizes(max_steps)                     \
@@ -210,6 +224,11 @@ main (int argc, char *argv[])
 {
   g_test_init (&argc, &argv, NULL);
 
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+  g_test_message ("GSlice will use a chunk size of %" G_GINT64_FORMAT,
+                  g_slice_get_config (G_SLICE_CONFIG_CHUNK_SIZES));
+  G_GNUC_END_IGNORE_DEPRECATIONS;
+
   g_test_add_func (TEST_BASENAME "/simple-type/gchar", test_allocation_gchar);
   g_test_add_func (TEST_BASENAME "/simple-type/gshort", test_allocation_gshort);
   g_test_add_func (TEST_BASENAME "/simple-type/glong", test_allocation_glong);
@@ -223,6 +242,9 @@ main (int argc, char *argv[])
   g_test_add_func (TEST_BASENAME "/simple-type/gdouble", test_allocation_gdouble);
   g_test_add_func (TEST_BASENAME "/simple-type/gpointer", test_allocation_gpointer);
 
+  /* FIXME: Depending on the OS we should only test up to the size that the
+   * GSlice would support, otherwise we'd get system allocator anyways.
+   */
   g_test_add_func (TEST_BASENAME "/sized/32", test_allocation_sized_32);
   g_test_add_func (TEST_BASENAME "/sized/64", test_allocation_sized_64);
   g_test_add_func (TEST_BASENAME "/sized/128", test_allocation_sized_128);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]