Try appending the following line to your test:
And then try to count how many times the string encoding(utf-8-strict)utf8repeats. In my case, it was 922 ×warn PerlIO::get_layers($handle{$file});
my @l = grep /utf-?8/, PerlIO::get_layers($handle{$file}); warn @l / 2;
To fix that, clear the layers before applying new ones by starting with :raw:
The result becomes agreeable:binmode $fh, ':raw:encoding(UTF-8)';
And the warning now shows a pretty low number.Rate close noclose close 2137/s -- -28% noclose 2951/s 38% --
Updated: Show how to count the repeated layers.
Update 2: On MSWin, you might need to add :crlf after :raw if needed, too.
In reply to Re: Why is using binmode on a file handle 77 times slower than just closing it and re-opening?
by choroba
in thread Why is using binmode on a file handle 77 times slower than just closing it and re-opening?
by Maelstrom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |