[glib/3v1n0/allocation-benchmarks: 2/2] allocator-tests: Add some machine-readable output
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/3v1n0/allocation-benchmarks: 2/2] allocator-tests: Add some machine-readable output
- Date: Fri, 8 Jul 2022 22:21:49 +0000 (UTC)
commit 51794f746a2d718cdbd4e75db740ef985d53b99f
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 f17dfa7851..8f71106571 100644
--- a/tests/allocators-tests.c
+++ b/tests/allocators-tests.c
@@ -42,6 +42,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; \
@@ -66,6 +73,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) \
@@ -87,6 +95,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 (); \
\
@@ -99,10 +108,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) \
@@ -157,6 +170,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) \
@@ -212,6 +226,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);
@@ -225,6 +244,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]