[gtk/css-style-split-2: 13/16] performance test: Produce better numbers
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/css-style-split-2: 13/16] performance test: Produce better numbers
- Date: Wed, 29 Jan 2020 10:13:48 +0000 (UTC)
commit 59994bdd2259a59ece2e4e0b1e5f47832b40997b
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jan 29 11:05:24 2020 +0100
performance test: Produce better numbers
Try to isolate the test runs from each other in the
eyes of the kernel scheduler, by sleeping a bit. And
ignore the first run, to avoid cache effects.
testsuite/performance/test-performance.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/testsuite/performance/test-performance.c b/testsuite/performance/test-performance.c
index 2dfbe3da66..fc0a7cfc36 100644
--- a/testsuite/performance/test-performance.c
+++ b/testsuite/performance/test-performance.c
@@ -56,6 +56,7 @@ main (int argc, char *argv[])
char fd_str[20];
gint64 *values;
gint64 min, max, total;
+ int count;
char *output_dir = NULL;
int i;
@@ -89,6 +90,8 @@ main (int argc, char *argv[])
g_object_unref (file);
}
+ opt_rep++;
+
values = g_new (gint64, opt_rep);
for (i = 0; i < opt_rep; i++)
@@ -101,9 +104,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);
@@ -164,24 +167,30 @@ main (int argc, char *argv[])
remove (name);
g_free (name);
+
+ /* A poor mans way to try and isolate the runs from each other */
+ g_usleep (300000);
}
min = G_MAXINT64;
max = 0;
+ count = 0;
total = 0;
- for (i = 0; i < opt_rep; i++)
+ /* Ignore the first run, to avoid cache effects */
+ for (i = 1; i < opt_rep; i++)
{
if (min > values[i])
min = values[i];
if (max < values[i])
max = values[i];
+ count++;
total += values[i];
}
g_print ("%d runs, min %g, max %g, avg %g\n",
- opt_rep,
+ count,
MILLISECONDS (min),
MILLISECONDS (max),
- MILLISECONDS (total / opt_rep));
+ MILLISECONDS (total / count));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]