From: Matthias Clasen Date: Wed, 22 Jan 2020 20:55:31 +0000 (-0500) Subject: ci: Save syscap files from performance tests X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~229 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3120fb29e1e5dc5acbe8f4303ffda1f41adf616e;p=gtk4.git ci: Save syscap files from performance tests They might become useful at some point. --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dbb0259b78..093f7e2d47 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/testsuite/css/meson.build b/testsuite/css/meson.build index 3a32c79691..3aa364347a 100644 --- a/testsuite/css/meson.build +++ b/testsuite/css/meson.build @@ -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' ]) diff --git a/testsuite/performance/test-performance.c b/testsuite/performance/test-performance.c index c4fbc54823..2dfbe3da66 100644 --- a/testsuite/performance/test-performance.c +++ b/testsuite/performance/test-performance.c @@ -1,4 +1,8 @@ #include +#include +#include +#include +#include #include #include @@ -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); }