I was wondering how expensive Java’s string encoding conversion algorithms are, say, for a piece of text is in EBCDIC that needs to be converted to UTF-16, or for a similar conversion of a large file. Are there any benchmarks on the cost of this conversion? Benchmarks for multiple encodings would be better.
I was wondering how expensive Java’s string encoding conversion algorithms are, say, for a
Share
This is an O(n) algorithm. The time it takes to execute will increase more or less linearly with the length of the string you’re converting (though if you are converting millions of very short strings, the overhead of the function calls will add to this).
In almost all situations this won’t be a bottleneck. You could probably encode very large strings many tens of megabytes in size in negligible time. I don’t have actual benchmark data though.