The result is:use Tk; use Benchmark qw(cmpthese); use MIME::Base64 qw(encode_base64); use LWP::Simple qw(get); my $mw = tkinit; my $file = Tk->findINC("Xcamel.gif"); my $data = get "file://$file"; # poor man's File::Slurp cmpthese(-1, { base64 => sub { my $p = $mw->Photo(-data => encode_base64($data)); $p->delete; }, binary => sub { my $p = $mw->Photo(-data => $data); $p->delete; } } );
I agree that the performance gain would be larger if no (unnecessary) conversion to utf-8 would occur at all. Maybe it's somehow possible to prevent this, for example by using a special reference or magics for the value of -data, which wouldn't be upgraded by Tcl_GetString calls.$ perl5.9.5d -Mblib=/home/e/eserte/work/svk-checkouts/Tk-debug ~/trash +/imgbench.pl Rate base64 binary base64 574/s -- -38% binary 926/s 61% --
But I think I have first to learn how the Perl/Tk internals work at all...
In reply to Re^6: Tk:Photo -data with binary data?
by eserte
in thread Tk:Photo -data with binary data?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |