Hello and slowness problem

1 view
Skip to first unread message

Toni

unread,
Apr 22, 2008, 6:27:33 AM4/22/08
to JSON/XML-RPC Client and Server Implementations
Hello,

I'm new to JSON/XML-RPC and I'm trying to use it for an AJAX /
database application

I find it very easy to use and without many problems (except for dates
and timezones)

My main concern, though, is that it is terribly slow when converting
to json

On a P4-3GHz sever it takes ~1200ms to return an array of approx 100
lines (each an array of 4 fields).

I don't know how to profile PHP but I'm pretty sure it is the
conversion to json because changing
my final line:

return $results;

into

#return $results;
return array(array("", "", "", ""));

reduces the request time from ~1400ms to ~200ms

switching to "XML-RPC" varies time but not much (about 50ms better)

It is all run locally over 127.0.0.1 so transmission time is certainly
not the main contributor.

Do you know of any way to improve this?

Thanks,

Toni

Toni

unread,
Apr 22, 2008, 7:24:55 AM4/22/08
to JSON/XML-RPC Client and Server Implementations
Answering to myself because I found some new data:

On 22 Abr, 12:27, Toni <devega...@gmail.com> wrote:
>
> On a P4-3GHz sever it takes ~1200ms to return an array of approx 100
> lines (each an array of 4 fields).
>

I found that approx 700 of those 1200 ms are due to FF painting the
table, so, after eliminating that painting, the real numbers are:

500ms when returning the array

80ms when converting the array to a single CSV style string and then
splitting back to array on browser

The string trick makes it much better, but I'd still like to know if
the array to json conversion can be improved a bit

Toni

Weston Ruter

unread,
Apr 22, 2008, 10:55:30 AM4/22/08
to json-x...@googlegroups.com
Have you tried turning off the sanitize option? As in:

new rpc.ServiceProxy("/app/service", {sanitize:false});

If the slowness is indeed in the parsing of the response, it can't imagine the speed being improved with sanitize turned off, because it is doing a JavaScript eval, which is blazing fast. Are you sure the slowness isn't happening when building and sending the request?
Reply all
Reply to author
Forward
0 new messages