From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Let lowlevel-blt-bench parse the test name string from the command line,
allowing to run almost infinitely more tests. One is no longer limited
to the tests listed in the big table.

While you can use the old short-hand names like src_8888_8888, you can
also use all possible operators now, and specify pixel formats exactly
rather than just x888, for instance.

This even allows to run crazy patterns like
conjoint_over_reverse_a8b8g8r8_n_r8g8b8x8.

All individual patterns are now interpreted through the parser. The
pattern "all" runs the same old default test set as before but through
the parser instead of the hard-coded parameters.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
 test/lowlevel-blt-bench.c | 64 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 20 deletions(-)

diff --git a/test/lowlevel-blt-bench.c b/test/lowlevel-blt-bench.c
index 7c1711b..9d80d21 100644
--- a/test/lowlevel-blt-bench.c
+++ b/test/lowlevel-blt-bench.c
@@ -367,14 +367,14 @@ bench_RT (pixman_op_t              op,
 }
 
 void
-bench_composite (char * testname,
-                 int    src_fmt,
-                 int    src_flags,
-                 int    op,
-                 int    mask_fmt,
-                 int    mask_flags,
-                 int    dst_fmt,
-                 double npix)
+bench_composite (const char *testname,
+                 int         src_fmt,
+                 int         src_flags,
+                 int         op,
+                 int         mask_fmt,
+                 int         mask_flags,
+                 int         dst_fmt,
+                 double      npix)
 {
     pixman_image_t *                src_img;
     pixman_image_t *                dst_img;
@@ -942,6 +942,36 @@ parser_self_test (void)
     printf ("Parser self-test complete.\n");
 }
 
+static void
+run_one_test (const char *pattern, double bandwidth_)
+{
+    test_entry_t test;
+
+    if (parse_test_pattern (&test, pattern) < 0)
+    {
+        printf ("Error: Could not parse the test pattern '%s'.\n", pattern);
+        return;
+    }
+
+    bench_composite (pattern,
+                     test.src_fmt,
+                     test.src_flags,
+                     test.op,
+                     test.mask_fmt,
+                     test.mask_flags,
+                     test.dst_fmt,
+                     bandwidth_ / 8);
+}
+
+static void
+run_default_tests (double bandwidth_)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
+        run_one_test (tests_tbl[i].testname, bandwidth_);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1026,19 +1056,13 @@ main (int argc, char *argv[])
     }
     printf ("---\n");
 
-    for (i = 0; i < ARRAY_LENGTH (tests_tbl); i++)
+    if (strcmp (pattern, "all") == 0)
     {
-       if (strcmp (pattern, "all") == 0 || strcmp (tests_tbl[i].testname, 
pattern) == 0)
-       {
-           bench_composite (tests_tbl[i].testname,
-                            tests_tbl[i].src_fmt,
-                            tests_tbl[i].src_flags,
-                            tests_tbl[i].op,
-                            tests_tbl[i].mask_fmt,
-                            tests_tbl[i].mask_flags,
-                            tests_tbl[i].dst_fmt,
-                            bandwidth/8);
-       }
+        run_default_tests (bandwidth);
+    }
+    else
+    {
+        run_one_test (pattern, bandwidth);
     }
 
     free (src);
-- 
2.0.5

_______________________________________________
Pixman mailing list
Pixman@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pixman

Reply via email to