[squeak-dev] WebClient, Json and CouchDB

Igor Stasenko siguctua at gmail.com
Thu May 13 01:11:37 UTC 2010


On 13 May 2010 04:02, Hannes Hirzel <hannes.hirzel at gmail.com> wrote:
> On 5/13/10, Igor Stasenko <siguctua at gmail.com> wrote:
>> My comment on
>> SqS/JSON/JSON-hjh.32
>>
>> guys, can you give me any idea, why you replaced back the
>>
>> stream peek / stream next
>>
>> by
>>
>> self peek / self next
>>
>> removed all uses of #peekFor:
>> and added:
>>
>> next
>>       ^ self stream next
>>
>> peek
>>       ^ self stream peek
>>
>>
>> you're seem little concerned with speed?
>
>
> The reason is that this change is in the following version
>
> Name: JSON-Igor.Stasenko.34
> Author: Igor.Stasenko
> Time: 7 April 2010, 1:58:24.739 am
> UUID: 4a92f912-177d-5941-9a4f-a773cb11f659
> Ancestors: JSON-Igor.Stasenko.33
>
> And I did not include this version 34 yet in http://www.squeaksource.com/JSON.
>
> Thank you for pointing this out. Yes, I realized that a local upload
> for 10000 records resulting in a 7MB compacted couchDB was a bit slow.
> I did not measure it though. My estimate is that it took 50 seconds.
> And maybe this it not slow - I don't know.
>
I measured , for what it worth, on a given json, a stream peek vesion
gives about 5% higher parsing speed:

|json |
 json := JsonObject new
	title: 'The title of my note card';
 	body: 'The body test text of my note card with some Unicode test characters ';
	foo: 10;
	bar: #( 10 'twenty' #thirty );
	bar1: #( 10 'twenty' #thirty );
	bar2: #( 10 'twenty' #thirty );
	bar3: #( 10 'twenty' #thirty );
	bar4: #( 10 'twenty' #thirty );
	bar5: #( 10 20 30 22 23 24 56 34 36 34 3 634 346 'twenty' #thirty );
      asJsonString.

[ 1000 timesRepeat: [ Json readFrom: json readStream ] ] timeToRun

with self peek/next:
1500
1485

with stream peek/next:

1431
1415

Also, i found that once you put more data in it, you'll get the more difference.
|json |
 json := JsonObject new
	bar: ((1 to: 1000) collect: [:i | i odd ifTrue: [i] ifFalse: [ 'x' ,
i asString ] ])
      asJsonString.

[ 100 timesRepeat: [ Json readFrom: json readStream ] ] timeToRun

self peek/next
3538
stream peek/next
3294

so now its 7%


> Hannes
>
>
> P.S. Regarding UTF8, please read my post carefully. It should not be
> in the JSON package. Currently all the code values > 128 are escaped
> so there is no need for it in case of storing documents. However I do
> not know yet how an elegant interface for getting it back properly
> should look like.
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list