{"issue":{"created_at":"2011-11-23T22:04:13Z","state":"open","updated_at":"2011-11-23T22:06:16Z","user":{"gravatar_id":"6afd1d1327b5825141358983e229ad5d","id":544750,"url":"https://api.github.com/users/codeconsole","login":"codeconsole","avatar_url":"https://secure.gravatar.com/avatar/6afd1d1327b5825141358983e229ad5d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":1,"body":"Manual coercion seems to be performing pretty bad.\r\n\r\nExample:\r\n\r\n\r\n\timport com.google.appengine.api.datastore.Entity\r\n\timport groovyx.gaelyk.GaelykCategory\r\n\timport org.springframework.util.StopWatch\r\n\timport groovyx.gaelyk.datastore.Key\r\n\timport groovy.transform.Canonical\r\n\r\n\tdef watch = new StopWatch(\"Coercion\")\r\n\r\n\t@Canonical\r\n\tclass Person {\r\n\t  @Key Long id\r\n\t  String name\r\n\t}\r\n  \r\n\tuse (GaelykCategory) {\r\n\t  watch.start(\"build\")\r\n\t  def entities = []\r\n\t  for (long i = 1; i < 200; i++) {\r\n\t    Entity entity = new Entity(\"Person\", i)\r\n\t    entity.name = \"Person ${i}\"\r\n\t    entities << entity\r\n\t  }  \r\n\t  watch.stop()\r\n\t  watch.start(\"manual coercion\")\r\n\t  entities.each {\r\n\t    it as Person\r\n\t  } \r\n\t  watch.stop()\r\n\t  watch.start(\"construction\")\r\n\t  entities.each {\r\n\t    new Person(it.id, it.name)\r\n\t  }   \r\n\t  watch.stop()\r\n\t  System.out.println watch.toString()\r\n\t}\r\n\r\nresult:\r\n\r\nStopWatch 'Coercion': running time (millis) = 576; [build] took 20 = 3%; [manual coercion] took 530 = 92%; [construction] took 26 = 5%","assignee":null,"id":2335275,"labels":[],"number":96,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"Manual Coercion Performance Seems Pretty Bad","closed_at":null,"html_url":"https://github.com/glaforge/gaelyk/issues/96","milestone":null,"url":"https://api.github.com/repos/glaforge/gaelyk/issues/96"},"action":"created","comment":{"created_at":"2011-11-23T22:06:16Z","updated_at":"2011-11-23T22:06:16Z","user":{"gravatar_id":"6afd1d1327b5825141358983e229ad5d","id":544750,"url":"https://api.github.com/users/codeconsole","login":"codeconsole","avatar_url":"https://secure.gravatar.com/avatar/6afd1d1327b5825141358983e229ad5d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"What do you think can be done to improve the performance? \r\n\r\nCreating as asType for a List?","id":2855553,"url":"https://api.github.com/repos/glaforge/gaelyk/issues/comments/2855553"}}