Skip to content

Instantly share code, notes, and snippets.

@Mons
Created Sep 25, 2010
Embed
What would you like to do?
use uni::perl;
use Benchmark ':all';
use lib::abs;
BEGIN {unshift @INC, lib::abs::path 'kraih/lib' }
use Mojo::ByteStream 'b';;
say $INC{'Mojo/ByteStream.pm'};
my %results;
$results{old1} = timethis -1 , sub { b("тестовая строка")->encode('utf8')->decode('utf8') };
$results{old2} = timethis -1 , sub { b("тестовая строка")->encode('utf-8')->decode('utf-8') };
$results{old} = timethis -1 , sub { b("тестовая строка")->encode('utf-8')->decode('utf-8')->encode('utf8')->decode('utf8') };
delete $INC{'Mojo/ByteStream.pm'};
delete $Mojo::{'ByteStream::'};
shift @INC;
unshift @INC, lib::abs::path 'mons/lib';
require Mojo::ByteStream;
Mojo::ByteStream->import('b');
say $INC{'Mojo/ByteStream.pm'};
$results{new1} = timethis -1 , sub { b("тестовая строка")->encode('utf8')->decode('utf8') };
$results{new2} = timethis -1 , sub { b("тестовая строка")->encode('utf-8')->decode('utf-8') };
$results{new} = timethis -1 , sub { b("тестовая строка")->encode('utf-8')->decode('utf-8')->encode('utf8')->decode('utf8') };
cmpthese \%results;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment