File: blur-performance.c

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (54 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */

#include <gsk/gskcairoblurprivate.h>

static void
init_surface (cairo_t *cr)
{
  int w = cairo_image_surface_get_width (cairo_get_target (cr));
  int h = cairo_image_surface_get_height (cairo_get_target (cr));

  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_fill (cr);

  cairo_set_source_rgb (cr, 1, 1, 1);
  cairo_arc (cr, w/2, h/2, w/2, 0, 2*G_PI);
  cairo_fill (cr);
}

int
main (int argc, char **argv)
{
  cairo_surface_t *surface;
  cairo_t *cr;
  GTimer *timer;
  double msec;
  int i, j;
  int size;

  timer = g_timer_new ();

  size = 2000;

  surface = cairo_image_surface_create (CAIRO_FORMAT_A8, size, size);

  cr = cairo_create (surface);

  /* We do everything three times, first two as warmup */
  for (j = 0; j < 2; j++)
    {
      for (i = 1; i < 16; i++)
	{
	  init_surface (cr);
	  g_timer_start (timer);
	  gsk_cairo_blur_surface (surface, i, GSK_BLUR_X | GSK_BLUR_Y);
	  msec = g_timer_elapsed (timer, NULL) * 1000;
	  if (j == 1)
	    g_print ("Radius %2d: %.2f msec, %.2f kpixels/msec:\n", i, msec, size*size/(msec*1000));
	}
    }

  g_timer_destroy (timer);

  return 0;
}