Groovy: Groovy Bean creating is longer than java.util.Map creating? -
class test {string field entry number public test (string field, int number) {this.field = this field .num = num}} def start = System.currentTimeMillis () def testObj = New Test ("I field", 1) println "Beans: $ {System.currentTimeMillis () - start}" def start2 = System.currentTimeMillis () DIF map = [:] map.field = "I field" map.num = 1 println "maps: $ {System.currentTimeMillis () - start2}"
Output is:
beans: 3 maps: 0
My Grails server communicates on JSON I & lt; -> Using JSON conversion but I think it is better that you use beans because in the case of maps you have to put several () methods to call ...
but simple The script shows that the map
text "itemprop =" text ">
your script is exactly It is meaningless The operation you are trying to measure is far away, your measurements are far below the limit Output is only random noise Repeat every assignment one hundred times and use System.nanoTime ()
, and then you can get meaningful data.
In any case, if any significant difference It is almost certainly not important for your application, it is a typical example of premature adaptation, that is, waste of time.
Comments
Post a Comment