Groovy web console

subscribe to the feed Subscribe
to this
site
containsAndEquals (via #groovywebconsole)
tweet this snippet Tweet
this
script

containsAndEquals

Published 9 months ago by zoeiro
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def speed = {name, executor ->   def start = System.currentTimeMillis()
   executor.call()
   println "Test '${name}': ${System.currentTimeMillis() - start}ms "
}

def items = [a:1, b:2, 'password':3, foo: 4, bar: 5, '1':1, '2':2, '3':3, '4':4, '5':5]

speed('Equals match') {
   10000.times {
       items.each {e -> e.key.contains('password') }
   }
}


speed('Equals match') {
   10000.times {
       items.each {e -> e.key ==  'password' }
   }
}