mirror of
https://salsa.debian.org/xorg-team/lib/pixman
synced 2025-08-26 08:24:15 +00:00

Wallclock time for running pixman "make check" (compile time not included): ----------------------------+----------------+-----------------------------+ | old PRNG (LCG) | new PRNG (Bob Jenkins) | Processor type +----------------+------------+----------------+ | gcc 4.5 | gcc 4.5 | gcc 4.7 (simd) | ----------------------------+----------------+------------+----------------+ quad Intel Core i7 @2.8GHz | 0m49.494s | 0m43.722s | 0m37.560s | dual ARM Cortex-A15 @1.7GHz | 5m8.465s | 4m37.375s | 3m45.819s | IBM Cell PPU @3.2GHz | 23m0.821s | 20m38.316s | 16m37.513s | ----------------------------+----------------+------------+----------------+ But some tests got a particularly large boost. For example benchmarking and profiling blitters-test on Core i7: === before === $ time ./blitters-test real 0m10.907s user 0m55.650s sys 0m0.000s 70.45% blitters-test blitters-test [.] create_random_image 15.81% blitters-test blitters-test [.] compute_crc32_for_image_internal 2.26% blitters-test blitters-test [.] _pixman_implementation_lookup_composite 1.07% blitters-test libc-2.15.so [.] _int_free 0.89% blitters-test libc-2.15.so [.] malloc_consolidate 0.87% blitters-test libc-2.15.so [.] _int_malloc 0.75% blitters-test blitters-test [.] combine_conjoint_general_u 0.61% blitters-test blitters-test [.] combine_disjoint_general_u 0.40% blitters-test blitters-test [.] test_composite 0.31% blitters-test libc-2.15.so [.] _int_memalign 0.31% blitters-test blitters-test [.] _pixman_bits_image_setup_accessors 0.28% blitters-test libc-2.15.so [.] malloc === after === $ time ./blitters-test real 0m3.655s user 0m20.550s sys 0m0.000s 41.77% blitters-test.n blitters-test.new [.] compute_crc32_for_image_internal 15.77% blitters-test.n blitters-test.new [.] prng_randmemset_r 6.15% blitters-test.n blitters-test.new [.] _pixman_implementation_lookup_composite 3.09% blitters-test.n libc-2.15.so [.] _int_free 2.68% blitters-test.n libc-2.15.so [.] malloc_consolidate 2.39% blitters-test.n libc-2.15.so [.] _int_malloc 2.27% blitters-test.n blitters-test.new [.] create_random_image 2.22% blitters-test.n blitters-test.new [.] combine_conjoint_general_u 1.52% blitters-test.n blitters-test.new [.] combine_disjoint_general_u 1.40% blitters-test.n blitters-test.new [.] test_composite 1.02% blitters-test.n blitters-test.new [.] prng_srand_r 1.00% blitters-test.n blitters-test.new [.] _pixman_image_validate 0.96% blitters-test.n blitters-test.new [.] _pixman_bits_image_setup_accessors 0.90% blitters-test.n libc-2.15.so [.] malloc
126 lines
2.9 KiB
C
126 lines
2.9 KiB
C
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "utils.h"
|
|
|
|
int
|
|
main ()
|
|
{
|
|
pixman_region32_t r1;
|
|
pixman_region32_t r2;
|
|
pixman_region32_t r3;
|
|
pixman_box32_t boxes[] = {
|
|
{ 10, 10, 20, 20 },
|
|
{ 30, 30, 30, 40 },
|
|
{ 50, 45, 60, 44 },
|
|
};
|
|
pixman_box32_t boxes2[] = {
|
|
{ 2, 6, 7, 6 },
|
|
{ 4, 1, 6, 7 },
|
|
};
|
|
pixman_box32_t boxes3[] = {
|
|
{ 2, 6, 7, 6 },
|
|
{ 4, 1, 6, 1 },
|
|
};
|
|
int i, j;
|
|
pixman_box32_t *b;
|
|
pixman_image_t *image, *fill;
|
|
pixman_color_t white = {
|
|
0xffff,
|
|
0xffff,
|
|
0xffff,
|
|
0xffff
|
|
};
|
|
|
|
prng_srand (0);
|
|
|
|
/* This used to go into an infinite loop before pixman-region.c
|
|
* was fixed to not use explict "short" variables
|
|
*/
|
|
pixman_region32_init_rect (&r1, 0, 0, 20, 64000);
|
|
pixman_region32_init_rect (&r2, 0, 0, 20, 64000);
|
|
pixman_region32_init_rect (&r3, 0, 0, 20, 64000);
|
|
|
|
pixman_region32_subtract (&r1, &r2, &r3);
|
|
|
|
|
|
/* This would produce a region containing an empty
|
|
* rectangle in it. Such regions are considered malformed,
|
|
* but using an empty rectangle for initialization should
|
|
* work.
|
|
*/
|
|
pixman_region32_init_rects (&r1, boxes, 3);
|
|
|
|
b = pixman_region32_rectangles (&r1, &i);
|
|
|
|
assert (i == 1);
|
|
|
|
while (i--)
|
|
{
|
|
assert (b[i].x1 < b[i].x2);
|
|
assert (b[i].y1 < b[i].y2);
|
|
}
|
|
|
|
/* This would produce a rectangle containing the bounding box
|
|
* of the two rectangles. The correct result is to eliminate
|
|
* the broken rectangle.
|
|
*/
|
|
pixman_region32_init_rects (&r1, boxes2, 2);
|
|
|
|
b = pixman_region32_rectangles (&r1, &i);
|
|
|
|
assert (i == 1);
|
|
|
|
assert (b[0].x1 == 4);
|
|
assert (b[0].y1 == 1);
|
|
assert (b[0].x2 == 6);
|
|
assert (b[0].y2 == 7);
|
|
|
|
/* This should produce an empty region */
|
|
pixman_region32_init_rects (&r1, boxes3, 2);
|
|
|
|
b = pixman_region32_rectangles (&r1, &i);
|
|
|
|
assert (i == 0);
|
|
|
|
fill = pixman_image_create_solid_fill (&white);
|
|
for (i = 0; i < 100; i++)
|
|
{
|
|
int image_size = 128;
|
|
|
|
pixman_region32_init (&r1);
|
|
|
|
/* Add some random rectangles */
|
|
for (j = 0; j < 64; j++)
|
|
pixman_region32_union_rect (&r1, &r1,
|
|
prng_rand_n (image_size),
|
|
prng_rand_n (image_size),
|
|
prng_rand_n (25),
|
|
prng_rand_n (25));
|
|
|
|
/* Clip to image size */
|
|
pixman_region32_init_rect (&r2, 0, 0, image_size, image_size);
|
|
pixman_region32_intersect (&r1, &r1, &r2);
|
|
pixman_region32_fini (&r2);
|
|
|
|
/* render region to a1 mask */
|
|
image = pixman_image_create_bits (PIXMAN_a1, image_size, image_size, NULL, 0);
|
|
pixman_image_set_clip_region32 (image, &r1);
|
|
pixman_image_composite32 (PIXMAN_OP_SRC,
|
|
fill, NULL, image,
|
|
0, 0, 0, 0, 0, 0,
|
|
image_size, image_size);
|
|
pixman_region32_init_from_image (&r2, image);
|
|
|
|
pixman_image_unref (image);
|
|
|
|
assert (pixman_region32_equal (&r1, &r2));
|
|
pixman_region32_fini (&r1);
|
|
pixman_region32_fini (&r2);
|
|
|
|
}
|
|
pixman_image_unref (fill);
|
|
|
|
return 0;
|
|
}
|