问题
I am attempting to use Restlet for Android to query an OData data source. However, I am not impressed with its performance in both the emulator as well on a real device. I have the requests made in a wrapper AsyncTask
to make the UI responsive but it still takes over 1 minute to finally return the objects.
I get plenty of these in the LogCat window:
10-04 18:20:41.667: DEBUG/dalvikvm(278): GC freed 7872 objects / 523928 bytes in 279ms
What can I do to speed up the queries?
回答1:
Check out odata4j - http://odata4j.org This is an alternative odata library for java, including an android-compatible client api.
We just released a simple android client example in our 0.3 release. This example demonstrates an efficient way of parsing/paging an arbitrary odata service.
Along with service driven paging (mentioned by Alex), we use the efficient xml pull parser implementation to parse the odata payload (we found heap activity/GCs to be the biggest perf bottleneck on android).
回答2:
I know this doesn't help you with the perf of the RESTlet library... but:
One thing to consider is using something called Service Driven Paging. Note this is distinct from $top and $skip (aka client driven paging), because the server pages even if the client doesn't ask for it.
SDP is particularly useful when a client does an unfiltered query over a large data set.
That way perhaps you can lower that 7872 number to something more manageable.
来源:https://stackoverflow.com/questions/3858041/how-can-i-speed-up-restlet-for-android-when-using-odata