Restlet does not seem to run as fast as I would expect. I was hoping someone
could point me how to get it running faster.
Looking at the examples, I've created a simple server:
import org.restlet.Server;
import org.restlet.data.Protocol;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
public class SimpleServer extends ServerResource {
public static void main(String[] args) throws Exception {
// Create the HTTP server and listen on port 8182
new Server(Protocol.HTTP, 8182, SimpleServer.class).start();
}
@Get
public String toString() {
return "hello, world";
}
}
I also have created a simple client:
import java.io.IOException;
import org.restlet.resource.ClientResource;
public class SimpleClient {
public static void main(String [] args) throws IOException {
// Create the client resource
ClientResource resource = new ClientResource("http://localhost:8182");
// Write the response entity on the console
long startTime = System.nanoTime();
// If getMethod 1 is used, I get 3.12 seconds.
// Setting getMethod 2 results in 2.30 seconds.
int getMethod = 2;
for( int i=0; i < 10; i++) {
if( getMethod == 1 )
resource.get().write(System.out);
else
new ClientResource("http://localhost:8182
").get().write(System.out);
}
long endTime = System.nanoTime();
System.out.println( (endTime-startTime) / 1000000000.0);
}
}
If both are running on the same system, I get can process 10 requests in 2.3
or 3.1 seconds depending on the method used. I'm not sure why creating a new
client resource is faster than reusing the old one. At any rate, I was
hoping to run at least 100 in one second. Any thoughts on why this is slow?
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2703772