I seem to be having some kind of performance problem trying to
retrieve the request entity.
I've tried a few different approaches, and I can't figure it out.
I'm using Restlet 1.0.5 with the bundled Simple server, Intel Core
Duo, Mac OS X 10.4.10, Java 5.0, Eclipse.
I've tried reducing my test case down to the bare bones.
At this point my test App looks like this:
import org.restlet.Restlet;
import org.restlet.Server;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
public class TestApp {
public static void main(String[] args) throws Exception {
Restlet restlet = new Restlet() {
@Override
public void handle(Request request, Response response) {
try {
response.setEntity(request.getEntity().getText(), MediaType.TEXT_PLAIN);
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
}
}
};
new Server(Protocol.HTTP, 3000, restlet).start();
}
}
and these are the only JAR files in my build path:
com.noelios.restlet.ext.simple_3.1.jar
com.noelios.restlet.jar
org.restlet.jar
org.simpleframework.jar
My JVM args are: -server -Xprof
My test script:
time curl -X POST -d @post.xml -H Content-Type:application/xml
http://localhost:3000/
post.xml is a 2.5K xml file.
No matter what I do, request.getEntity().getText() seems to take about
2 seconds. This seems way too slow.
Looking through the profiling results I found:
Flat profile of 4.02 secs (390 total ticks): Thread-17
Interpreted + native Method
97.3% 0 + 183 java.net.SocketInputStream.socketRead0
1.1% 2 + 0 java.lang.AbstractStringBuilder.<init>
0.5% 1 + 0 java.lang.ClassLoader.loadClassInternal
0.5% 1 + 0 java.util.Arrays.copyOf
0.5% 1 + 0 sun.misc.Resource.getBytes
100.0% 5 + 183 Total interpreted
So it looks as though java.net.SocketInputStream.socketRead0 is taking
a lot of time - I think. I'm still new to Java, so not exactly sure
how to read this.
Could this be something wrong with my system configuration? Am I
missing something?
Thanks for any help!!!
--
Avi Flax
Lead Technologist
arc90 | http://arc90.com