3 use Benchmark qw(:hireswallclock countit);
7 #Imager->open_log(log => "circlef.log", loglevel => 2);
9 print $INC{"Imager.pm"}, "\n";
11 my $im = Imager->new(xsize => 1000, ysize => 1000);
12 my $im_pal = Imager->new(xsize => 1000, ysize => 1000, type => "paletted");
13 my @colors = map Imager::Color->new($_), qw/red green blue white black/;
14 $im_pal->addcolors(colors => \@colors);
15 my $color = $colors[0];
16 my $other = Imager::Color->new("pink");
17 my $fill = Imager::Fill->new(solid => "#ffff0080", combine => "normal");
23 $im->circle(color => $color, r => 2, x => 20, y => 75, aa => 1)
27 $im->circle(color => $color, r => 10, x => 20, y => 25, aa => 1)
31 $im->circle(color => $color, r => 60, x => 70, y => 80, aa => 1)
35 $im->circle(color => $color, r => 400, x => 550, y => 580, aa => 1)
40 $im->circle(fill => $fill, r => 2, x => 20, y => 75, aa => 1)
43 small_fill_aa => sub {
44 $im->circle(fill => $fill, r => 10, x => 20, y => 25, aa => 1)
47 medium_fill_aa => sub {
48 $im->circle(fill => $fill, r => 60, x => 70, y => 80, aa => 1)
51 large_fill_aa => sub {
52 $im->circle(fill => $fill, r => 400, x => 550, y => 580, aa => 1)
58 #$im_pal->type eq "paletted" or die "Not paletted anymore";
61 my ($limit, $what) = @_;
63 for my $key (sort keys %$what) {
64 my $bench = countit($limit, $what->{$key});
65 printf "$key: %.1f /s (%f / iter)\n", $bench->iters / $bench->cpu_p,
66 $bench->cpu_p / $bench->iters;
74 large_c_aa: 0.1 /s (13.110000 / iter)
75 large_fill_aa: 0.5 /s (2.026667 / iter)
76 medium_c_aa: 0.7 /s (1.402500 / iter)
77 medium_fill_aa: 1.9 /s (0.513000 / iter)
78 small_c_aa: 4.3 /s (0.230909 / iter)
79 small_fill_aa: 9.9 /s (0.100962 / iter)
80 tiny_c_aa: 17.4 /s (0.057444 / iter)
81 tiny_fill_aa: 25.7 /s (0.038947 / iter)
83 use a better algorithm for i_circle_aa() circle calculation:
85 large_c_aa: 1.3 /s (0.797143 / iter)
86 large_fill_aa: 0.5 /s (2.013333 / iter)
87 medium_c_aa: 32.2 /s (0.031012 / iter)
88 medium_fill_aa: 1.9 /s (0.523000 / iter)
89 small_c_aa: 166.8 /s (0.005993 / iter)
90 small_fill_aa: 9.9 /s (0.101373 / iter)
91 tiny_c_aa: 252.1 /s (0.003967 / iter)
92 tiny_fill_aa: 25.7 /s (0.038897 / iter)
94 add i_circle_aa_fill() and use it:
96 large_c_aa: 1.1 /s (0.948333 / iter)
97 large_fill_aa: 0.7 /s (1.500000 / iter)
98 medium_c_aa: 31.0 /s (0.032303 / iter)
99 medium_fill_aa: 22.1 /s (0.045175 / iter)
100 small_c_aa: 223.1 /s (0.004482 / iter)
101 small_fill_aa: 218.1 /s (0.004585 / iter)
102 tiny_c_aa: 394.4 /s (0.002536 / iter)
103 tiny_fill_aa: 437.8 /s (0.002284 / iter)