6 This program benchmarks various RGB to palette index code segments (quant.c).
8 The idea is to run it on various processors to see which is fastest on
11 It takes about 50 minutes on my 700MHz PIII laptop.
13 If you want to see what the output images look like, cd to .. and run:
15 perl -Mblib bench/quantone.perl foo
17 which gives the output files a prefix of 'foo'.
21 -e 'hsvgrad.png' && -e 'rgbtile.png'
22 or die "Run makegrad.perl first";
24 or die "Missing file. Download http://www.develop-help.com/imager/kscdisplay.png";
25 chdir ".." or die "Can't chdir to parent: $!";
27 #my %qopts = qw(linsearch IM_CFLINSEARCH
28 # hashbox IM_CFHASHBOX
29 # sortchan IM_CFSORTCHAN
30 # rand2dist IM_CFRAND2DIST);
32 my %qopts = qw(hashbox IM_CFHASHBOX
33 rand2dist IM_CFRAND2DIST);
36 # $bench{$opt}{$image}{$tran}{$pal} = time
39 unlink "bench/quantbench.txt";
40 for my $opt (keys %qopts) {
41 open LOG, ">> bench/quantbench.log" or die "Cannot open log: $!";
42 print LOG "*** $opt ***\n";
44 $ENV{IM_CFLAGS} = "-DIM_CF_COPTS -D$qopts{$opt}";
45 print "*** $opt configuring";
46 system "perl Makefile.PL >>bench/quantbench.log 2>&1"
47 and die "Failed to configure Imager";
49 system "make >>bench/quantbench.log 2>&1"
50 and die "Failed to build Imager";
51 print " benchmarking";
52 my @out = `perl -Mblib bench/quantone.perl`;
53 $? and die "Failed to run benchmark: $?";
58 if (/^\*\*\s+(\S+)\s+(\S+)/) {
62 elsif (/^\s*(\w+).*\@\s*([\d.]+)/ or /^\s*(\w+?):.+?([\d.]+?) CPU\)/) {
64 $bench{$opt}{$image}{$tran}{$1} = $2;
66 elsif (/^Benchmark:/) {
70 die "Unknown benchmark output: $_\n";
75 system "uname -srmp >bench/quantbench.txt"; # is -srmp portable?
76 open BENCH, ">> bench/quantbench.txt"
77 or die "Cannot open bench/quantbench.txt: $!";
78 print BENCH Dumper(\%bench);
79 close BENCH or die "Cannot close benchmark file: $!";
80 print "Please email bench/quantbench.txt to tony\@develop-help.com\n";
86 quantbench.pl - Benchmarks Imager's image quantization code.
95 Builds Imager with various quantization code options, and then times
96 the results of running with those options, with various palettes and
99 The aim is to run this with several options on several platforms, and
100 see which produces the fastest results overall.
102 Requires that PNG and GIF (or ungif) support is present.