[gtk/wip/matthiasc/sortlistmodel] sorting: Allow setting the random seed



commit 5a4840b245612ef33b26430014178252603b8370
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 11 14:52:41 2020 -0400

    sorting: Allow setting the random seed
    
    This makes runs reproducible, letting us compare
    various models and parameters.

 tests/sorting.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/tests/sorting.c b/tests/sorting.c
index 507c9ca81b..a3aae981b6 100644
--- a/tests/sorting.c
+++ b/tests/sorting.c
@@ -64,6 +64,18 @@ start_sort (gpointer data)
 int main (int argc, char *argv[])
 {
   GListModel *model;
+  guint32 seed;
+
+  seed = g_random_int ();
+
+  if (argc > 2)
+    {
+      if (strcmp (argv[1], "--seed") == 0)
+        seed = atoi (argv[2]);
+    }
+
+  g_print ("seed %u\n", seed);
+  g_random_set_seed (seed);
 
   gtk_init ();
 


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