[Pixman] [PATCH] test: safeguard the scaling-bench test against COW

Siarhei Siamashka siarhei.siamashka at gmail.com
Tue Sep 3 17:12:51 PDT 2013


The calloc call from pixman_image_create_bits may still
rely on http://en.wikipedia.org/wiki/Copy-on-write
Explicitly initializing the destination image results in
a more predictable behaviour.
---
 test/scaling-bench.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/test/scaling-bench.c b/test/scaling-bench.c
index b39adef..5a04a8f 100644
--- a/test/scaling-bench.c
+++ b/test/scaling-bench.c
@@ -27,10 +27,12 @@ int
 main ()
 {
     double scale;
-    pixman_image_t *src;
+    pixman_color_t fill = { 0, 0, 0, 0 };
+    pixman_image_t *src, *solid;
 
     prng_srand (23874);
     
+    solid = pixman_image_create_solid_fill (&fill);
     src = make_source ();
     printf ("# %-6s %-22s   %-14s %-12s\n",
 	    "ratio",
@@ -52,6 +54,14 @@ main ()
 	dest = pixman_image_create_bits (
 	    PIXMAN_a8r8g8b8, dest_width, dest_height, NULL, -1);
 
+	/* The calloc call from pixman_image_create_bits may still rely
+	 * on COW. Explicitly initializing the destination image results
+	 * in a more predictable behaviour.
+	 */
+	pixman_image_composite (
+	    PIXMAN_OP_SRC, solid, NULL, dest,
+	    0, 0, 0, 0, 0, 0, dest_width, dest_height);
+
 	t1 = gettime();
 	pixman_image_composite (
 	    PIXMAN_OP_OVER, src, NULL, dest,
@@ -64,6 +74,7 @@ main ()
 
 	pixman_image_unref (dest);
     }
+    pixman_image_unref (solid);
 
     return 0;
 }
-- 
1.8.1.5



More information about the Pixman mailing list