On 31.08.2010 00:34, Levente Uzonyi wrote:
On Tue, 31 Aug 2010, Levente Uzonyi wrote:
On Mon, 30 Aug 2010, Henrik Johansen wrote:
snip
"MediumDoc is a pure ascii ByteString of size 4096" [1 to: 100000 do: [:ix |MediumDoc squeakToUtf8]] timeToRun 362 384 [1 to: 100000 do: [:ix | MediumDoc convertToEncoding: 'utf-8']] timeToRun 437 564
And another with "SmallDoc":
smallDoc := ByteString new: 20 streamContents: [ :stream | 20 timesRepeat: [ stream nextPut: (Character value: 128 atRandom - 1) ] ]. (1 to: 5) collect: [ :run | [ 1 to: 100000 do: [ :ix | smallDoc squeakToUtf8 ] ] timeToRun ]. "===> #(15 15 15 15 15)" (1 to: 5) collect: [ :run | [ 1 to: 100000 do: [ :ix | smallDoc convertToWithConverter: UTF8TextConverter new ] ] timeToRun ]. "===> #(34 34 34 35 32)" (1 to: 5) collect: [ :run | [ 1 to: 100000 do: [ :ix | smallDoc convertToEncoding: 'utf-8' ] ] timeToRun ]. "===> #(1256 1258 1259 1260 1260)"
smallDoc := ByteString new: 20 streamContents: [ :stream | 20 timesRepeat: [ stream nextPut: (Character value: 128 atRandom - 1) ] ]. smallDoc at: 10 put: (Character value: 129). (1 to: 5) collect: [ :run | [ 1 to: 100000 do: [ :ix | smallDoc squeakToUtf8 ] ] timeToRun ]. "===> #(115 112 112 113 112)" (1 to: 5) collect: [ :run | [ 1 to: 100000 do: [ :ix | smallDoc convertToWithConverter: UTF8TextConverter new ] ] timeToRun ]. "===> #(157 125 124 126 125)" (1 to: 5) collect: [ :run | [ 1 to: 100000 do: [ :ix | smallDoc convertToEncoding: 'utf-8' ] ] timeToRun ]. "===> #(1416 1419 1419 1429 1428)"
Levente Yeah, that's why I added the 200000 4KB docs / sec number. I really doubt the conversion will be a significant part of the processing time if what you send out is so small you are able to convert 800k messages per second...
See the code I attached last mail, switching to convertToEncoding: 'utf8' sort of implied implementing something like that, which gives it nearly the same speed as convertToWithConverter: UTF8TextConverter new in your examples. IMHO, that might be a nice tradeoff between speed and the two desires of not bringing back #squeakToUtf8 in Pharo, nor having to use the convertToWithConverter: call Andreas was strongly opposed to (and which I agree is rather ugly). Cheers, Henry