develooper Front page | perl.perl5.porters | Postings from January 2006

Unicode slowdown 5.8.6 -> 5.8.7

Thread Next
From:
Phil Pennock
Date:
January 26, 2006 15:57
Subject:
Unicode slowdown 5.8.6 -> 5.8.7
Message ID:
20060126205046.GD31922@parhelion.globnix.org
I originally sent this to the NL Perlmongers, but the only response I've
had suggested sending to perl5-porters, so I guess that I'm not missing
anything really obvious or well-known.  I'm not subscribed, so please CC
me on a response.  Thanks.

Does anyone know why it takes so much longer to use the charnames
utilities in Perl 5.8.7 than in 5.8.6?

I wrote a simple utility script, to take some Unicode named characters
and display them for demonstration purposes.  1602 charnames in input.

Run on 5.8.6 on Gentoo/x86 (Intel Xeon 2.8GHz) I get:
./display_unicode_namedchars < CharNames  1.07s user 0.01s system 94% cpu 1.138 total

Run remotely on 5.8.7 on Gentoo/x86 (AMD Athlon XP 2500+) I get similar
results (ballpark) to 5.8.7 on FreeBSD/x86 on Xeon run locally; namely:
./display_unicode_namedchars < CharNames  47.00s user 1.77s system 99% cpu 48.786 total

It's not the X server and it's not the OS; running a simple check of
loading the modules on the 5.8.7 box shows that it's not that:
% time perl -Mencoding=utf-8 -Mcharnames=:full -e 1
perl -Mencoding=utf-8 -Mcharnames=:full -e 1  0.03s user 0.01s system % 99% cpu 0.038 total

In both cases, $charnames::VERSION is 1.04 ...

So something weird seems to be going on.

Any ideas?

The CharNames list used, in case it matters, is available at:
  http://www.globnix.org/help-snippets/perl/CharNames
and another copy of the script below is at:
  http://www.globnix.org/help-snippets/perl/display_unicode_namedchars

CharNames is just under 40k.

display_unicode_namedchars:
-----------------------------< cut here >-------------------------------
#!/usr/bin/perl
use warnings;
use strict;

use encoding qw/utf-8/;
use charnames qw/:full/;
use Term::ReadKey;

my ($width) = Term::ReadKey::GetTerminalSize STDOUT;
my $per_line = ($width - 3) / 2;

my @list;

while (<ARGV>) {
	chomp;
	s/^\s+//; s/\s+\z//;
	next unless /./;
	last if /^-/;
	push @list, chr(charnames::vianame($_) || 0xfffd);
}

while (my @line = splice(@list, 0, $per_line)) {
	print "@line\n";
}
-----------------------------< cut here >-------------------------------

-- 
I am keeping international relations on a peaceable footing.
You are biding your time before acting.
He is coddling tyrants.
 -- Roger BW on topic of verb conjugation

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About