File: unibench.pl

package info (click to toggle)
libjcode-pm-perl 2.07-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,440 kB
  • sloc: perl: 14,814; ansic: 11,032; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 727 bytes parent folder | download | duplicates (3)
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
#!/usr/local/bin/perl

use strict;
use Benchmark;
use blib;

$| = 1;

my %code2str;

my @enc = qw/euc sjis jis utf8/;
for my $enc (@enc){
    my $file = "t/table.$enc";
    open F, $file or die "$file:$!";
    binmode F;
    read F, $code2str{$enc}, -s $file;
    close F;
}

use Jcode;
use Unicode::Japanese;
my $tests;

for my $f (@enc){
    for my $t (@enc){
	$f eq $t and next;
	$tests->{"$f->$t"} = 
	    sub {
		no strict 'refs';
		Jcode->new($code2str{$f}, $f)->$t eq $code2str{$t}
			or die;
	    };
    }
}

timethese(0,
	  $tests);
__END__
my %tests;
for my $mod (qw/Jcode Unicode::Japanese/){
    eval qq{ require $mod };
    $@ and next;
    "$mod loaded.";
    no strict 'refs';
    $tests{$mod} = sub {
	
    }
}