ci: Save syscap files from performance tests
authorMatthias Clasen <mclasen@redhat.com>
Wed, 22 Jan 2020 20:55:31 +0000 (15:55 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 22 Jan 2020 20:55:31 +0000 (15:55 -0500)
They might become useful at some point.

.gitlab-ci.yml
testsuite/css/meson.build
testsuite/performance/test-performance.c

index dbb0259b78eaf687f12a4fa5ca3fd70c8bd37143..093f7e2d474e63e0b28039e708ec67727b4d628a 100644 (file)
@@ -29,6 +29,7 @@ fedora-x86_64: &fedora-x86_64-defaults
       - "${CI_PROJECT_DIR}/_build/report.html"
       - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png"
       - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png"
+      - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap"
   cache:
     key: "$CI_JOB_NAME"
     <<: *cache-paths
index 3a32c7969118221a1f2d72497863bd4a4591632c..3aa364347a87974f4413d4e9d9a2f9f7b5958b5a 100644 (file)
@@ -49,13 +49,19 @@ endif
 if get_option ('profiler')
 
   test('performance-adwaita', test_performance,
-       args: [ '--mark', 'style', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
+       args: [ '--mark', 'style',
+               '--name',  'performance-adwaita',
+               '--output', join_paths(meson.current_build_dir(), 'output'),
+               join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
        env: [ 'GTK_THEME=Adwaita',
               'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
        suite: [ 'css' ])
 
   test('performance-empty', test_performance,
-       args: [ '--mark', 'style', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
+       args: [ '--mark', 'style',
+               '--name',  'performance-empty',
+               '--output', join_paths(meson.current_build_dir(), 'output'),
+               join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
        env: [ 'GTK_THEME=Empty',
               'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
        suite: [ 'css' ])
index c4fbc54823c48d9790c18d01ffe252de633725a8..2dfbe3da667dd7b0f946f2dbe8c6a6f4f6d0bce8 100644 (file)
@@ -1,4 +1,8 @@
 #include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
 #include <sysprof-capture.h>
 #include <gio/gio.h>
 
@@ -31,10 +35,14 @@ callback (const SysprofCaptureFrame *frame,
 
 static int opt_rep = 10;
 static char *opt_mark;
+static char *opt_name;
+static char *opt_output;
 
 static GOptionEntry options[] = {
   { "mark", 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &opt_mark, "Name of the mark", "NAME" },
-  { "runs", 'r', G_OPTION_FLAG_NONE, G_OPTION_ARG_INT, &opt_rep, "Number of runs", "COUNT" },
+  { "runs", '0', G_OPTION_FLAG_NONE, G_OPTION_ARG_INT, &opt_rep, "Number of runs", "COUNT" },
+  { "name", '0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &opt_name, "Name of this test", "NAME" },
+  { "output", '0', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &opt_output, "Directory to save syscap files", "DIRECTORY" },
   { NULL, }
 };
 
@@ -48,6 +56,7 @@ main (int argc, char *argv[])
   char fd_str[20];
   gint64 *values;
   gint64 min, max, total;
+  char *output_dir = NULL;
   int i;
 
   context = g_option_context_new ("COMMANDLINE");
@@ -64,6 +73,22 @@ main (int argc, char *argv[])
   if (opt_rep < 1)
     g_error ("COUNT must be a positive number");
 
+  if (opt_output)
+    {
+      GError *err = NULL;
+      GFile *file;
+
+      file = g_file_new_for_commandline_arg (opt_output);
+      if (!g_file_make_directory_with_parents (file, NULL, &err))
+        {
+          if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS))
+            g_error ("%s", err->message);
+        }
+
+      output_dir = g_file_get_path (file);
+      g_object_unref (file);
+    }
+
   values = g_new (gint64, opt_rep);
 
   for (i = 0; i < opt_rep; i++)
@@ -76,9 +101,9 @@ main (int argc, char *argv[])
       SysprofCaptureCursor *cursor;
       SysprofCaptureCondition *condition;
 
-      fd = g_file_open_tmp ("gtk.XXXXXX.syscap", &name, &error);
-      if (error)
-        g_error ("Create syscap file: %s", error->message);
+       fd = g_file_open_tmp ("gtk.XXXXXX.syscap", &name, &error);
+       if (error)
+         g_error ("Create syscap file: %s", error->message);
 
       launcher = g_subprocess_launcher_new (0);
       g_subprocess_launcher_take_fd (launcher, fd, fd);
@@ -119,7 +144,24 @@ main (int argc, char *argv[])
       sysprof_capture_cursor_unref (cursor);
       sysprof_capture_reader_unref (reader);
 
-      remove (name);
+      if (output_dir)
+        {
+          GFile *src, *dest;
+          char * save_to;
+
+          save_to = g_strdup_printf ("%s/%s.%d.syscap", output_dir, opt_name ? opt_name : "gtk", i);
+
+          src = g_file_new_for_path (name);
+          dest = g_file_new_for_path (save_to);
+          if (!g_file_copy (src, dest, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error))
+            g_error ("%s", error->message);
+
+          g_free (save_to);
+          g_object_unref (src);
+          g_object_unref (dest);
+        }
+      else
+        remove (name);
 
       g_free (name);
     }