couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 7zark7 <>
Subject Observation on REST lib performance
Date Sun, 20 Dec 2009 21:22:11 GMT
Not specifically about CouchDB, but have been experimenting with 
REST-based Java/Groovy DAOs using CouchDB as the backend.  Thought folks 
here might be interested in the info.

I created some REST DAOs using Groovy's HttpBuilder, and Spring's 
RestTemplate.   Both use Google's GSON library for serializing to JSON.

Examples of create method:

Spring's RestTemplate implementation:

     public String create(Pojo pojo) {
         Map response = restTemplate.postForObject(url, pojo, Map.class);
         String id = (String)response.get("id");
         String rev = (String)response.get("rev");

         return pojo.getKey();

Groovy's HttpBuilder implementation:

     String create(Pojo pojo) {
         httpBuilder.request(POST, JSON) {
             send JSON, toJson(pojo)
             response.success = {resp, json ->
                 pojo.key = as String
                 pojo.revision = json.rev as String

I found that the Spring implementation is nearly 50 times faster than 
the Groovy implementation.  Of course, the Groovy implementation was 
much easier to implement the Couch API with and was great for prototyping.

I can make a blog post somewhere if folks are interested in further code 


View raw message