mirror of
https://salsa.debian.org/xorg-team/lib/pixman
synced 2025-09-01 10:35:16 +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
112 lines
2.6 KiB
C
112 lines
2.6 KiB
C
#include <stdlib.h>
|
|
#include "utils.h"
|
|
|
|
#define WIDTH 32
|
|
#define HEIGHT 32
|
|
|
|
static const pixman_format_code_t formats[] =
|
|
{
|
|
PIXMAN_a8r8g8b8,
|
|
PIXMAN_a8b8g8r8,
|
|
PIXMAN_x8r8g8b8,
|
|
PIXMAN_x8b8g8r8,
|
|
PIXMAN_r5g6b5,
|
|
PIXMAN_b5g6r5,
|
|
PIXMAN_a8,
|
|
PIXMAN_a1,
|
|
};
|
|
|
|
static const pixman_op_t ops[] =
|
|
{
|
|
PIXMAN_OP_OVER,
|
|
PIXMAN_OP_SRC,
|
|
PIXMAN_OP_ADD,
|
|
};
|
|
|
|
#define TRANSFORM(v00, v01, v10, v11) \
|
|
{ { { v00, v01, WIDTH * pixman_fixed_1 / 2 }, \
|
|
{ v10, v11, HEIGHT * pixman_fixed_1 / 2 }, \
|
|
{ 0, 0, pixman_fixed_1 } } }
|
|
|
|
#define F1 pixman_fixed_1
|
|
|
|
static const pixman_transform_t transforms[] =
|
|
{
|
|
TRANSFORM (0, -1, 1, 0), /* wrong 90 degree rotation */
|
|
TRANSFORM (0, 1, -1, 0), /* wrong 270 degree rotation */
|
|
TRANSFORM (1, 0, 0, 1), /* wrong identity */
|
|
TRANSFORM (-1, 0, 0, -1), /* wrong 180 degree rotation */
|
|
TRANSFORM (0, -F1, F1, 0), /* correct 90 degree rotation */
|
|
TRANSFORM (0, F1, -F1, 0), /* correct 270 degree rotation */
|
|
TRANSFORM (F1, 0, 0, F1), /* correct identity */
|
|
TRANSFORM (-F1, 0, 0, -F1), /* correct 180 degree rotation */
|
|
};
|
|
|
|
#define RANDOM_FORMAT() \
|
|
(formats[prng_rand_n (ARRAY_LENGTH (formats))])
|
|
|
|
#define RANDOM_OP() \
|
|
(ops[prng_rand_n (ARRAY_LENGTH (ops))])
|
|
|
|
#define RANDOM_TRANSFORM() \
|
|
(&(transforms[prng_rand_n (ARRAY_LENGTH (transforms))]))
|
|
|
|
static void
|
|
on_destroy (pixman_image_t *image, void *data)
|
|
{
|
|
free (data);
|
|
}
|
|
|
|
static pixman_image_t *
|
|
make_image (void)
|
|
{
|
|
pixman_format_code_t format = RANDOM_FORMAT();
|
|
uint32_t *bytes = malloc (WIDTH * HEIGHT * 4);
|
|
pixman_image_t *image;
|
|
|
|
prng_randmemset (bytes, WIDTH * HEIGHT * 4, 0);
|
|
|
|
image = pixman_image_create_bits (
|
|
format, WIDTH, HEIGHT, bytes, WIDTH * 4);
|
|
|
|
pixman_image_set_transform (image, RANDOM_TRANSFORM());
|
|
pixman_image_set_destroy_function (image, on_destroy, bytes);
|
|
pixman_image_set_repeat (image, PIXMAN_REPEAT_NORMAL);
|
|
|
|
image_endian_swap (image);
|
|
|
|
return image;
|
|
}
|
|
|
|
static uint32_t
|
|
test_transform (int testnum, int verbose)
|
|
{
|
|
pixman_image_t *src, *dest;
|
|
uint32_t crc;
|
|
|
|
prng_srand (testnum);
|
|
|
|
src = make_image ();
|
|
dest = make_image ();
|
|
|
|
pixman_image_composite (RANDOM_OP(),
|
|
src, NULL, dest,
|
|
0, 0, 0, 0, WIDTH / 2, HEIGHT / 2,
|
|
WIDTH, HEIGHT);
|
|
|
|
crc = compute_crc32_for_image (0, dest);
|
|
|
|
pixman_image_unref (src);
|
|
pixman_image_unref (dest);
|
|
|
|
return crc;
|
|
}
|
|
|
|
int
|
|
main (int argc, const char *argv[])
|
|
{
|
|
return fuzzer_test_main ("rotate", 15000,
|
|
0xECF5E426,
|
|
test_transform, argc, argv);
|
|
}
|