[squeak-dev] WebClient, Json and CouchDB

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


i tried to compare speed of two backends (SCouchDb and WebClient)
to find a winner.. but unfortunately WebClient stops with error, while
mine works ok.

Here a doit (maybe Andreas could say something about it):

--------------

|json couchDBurl |
 json := JsonObject new.
 json title: 'The title of my note card'.
 json body: 'The body test text of my note card with some Unicode
test characters ',
                  (8450 asCharacter asString, 'ä.', Character cr).
 json myTestArray: ((1 to: 1000) collect: [:i | i odd ifTrue: [i]
ifFalse: [ 'x' ,
i asString ] ]).

"create couchDB instance"
couchDBurl := 'http://192.168.0.11:5984/foo'.

WebClient httpPut: couchDBurl
                content: ''
                type: 'text/plain'.

"Store first document"
[1 to: 1000 do: [ :i |
WebClient httpPut: couchDBurl, '/myNote', i printString
                content: json asJsonString
                type: 'text/plain'.]] timeToRun printString.

-------------------

i thought that maybe its because some recent updates to SocketStream,
Andreas mentioned.
I updated image to recent trunk (to 10143 now),
but still i get a walkback, when WebResponse trying to read a response
header in #readFrom: aStream

status := stream upToAll: String crlf.

and got status = ''.

i running it on windoze.

And here the doit, which works:
------------
|json db time |
 json := JsonObject new.
 json title: 'The title of my note card'.
 json body: 'The body test text of my note card with some Unicode
test characters ',
                  (8450 asCharacter asString, 'ä.', Character cr).
 json myTestArray: ((1 to: 1000) collect: [:i | i odd ifTrue: [i]
ifFalse: [ 'x' ,
i asString ] ]).


db := SCouchDBAdaptor new host: '192.168.0.11'; ensureDatabase: 'foo'.

time := [1 to: 1000 do: [ :i |
		db documentAt: 'myNote', i printString
		put: json ]] timeToRun printString.

db adaptor deleteDatabase: 'foo'.
time
---------------

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list