File: unibench.pl

package info (click to toggle)
libjcode-pm-perl 0.60-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 888 kB
  • ctags: 92
  • sloc: perl: 14,211; ansic: 13,219; makefile: 57
file content (47 lines) | stat: -rw-r--r-- 697 bytes parent folder | download
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
#!/usr/local/bin/perl

use ExtUtils::testlib;
use Benchmark;

$| = 1;


print "Jcode Loading...\n";
require Jcode;
$Jcode::DEBUG = 1;
print "done.\n";

$file = "t/table.euc";
open F, $file or die "$file:$!";
my $euc;
read F, $euc, -s $file;

my $ucs2 = Jcode->new($euc)->ucs2;
my $utf8 = Jcode->new($euc)->utf8;

my $count = $ARGV[0] || 16;

timethese($count, {
    "utf8->ucs2" =>  \&utf8_ucs2,
    "ucs2->utf8" =>  \&ucs2_utf8,
    "euc->ucs2"  =>  \&euc_ucs2,
    "ucs2->euc"  =>  \&ucs2_euc,
    }
	  );


sub utf8_ucs2{
    &Jcode::utf8_ucs2($utf8);
}

sub ucs2_utf8{
    &Jcode::ucs2_utf8($ucs2);
}

sub euc_ucs2{
    &Jcode::euc_ucs2($ucs2);
}

sub ucs2_euc{
    &Jcode::ucs2_euc($ucs2);
}