Created
July 13, 2014 03:27
-
-
Save jeffscottbrown/1a30d1c1b23d2fd4ee9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='org.gperfutils', module='gbench', version='0.4.2-groovy-2.1') | |
def smallList = [[first: 'John', last: 'test']] | |
def largListWithMatchAtEnd = [] | |
10000.times { largListWithMatchAtEnd << [first: 'Johnx', last: 'test'] } | |
largListWithMatchAtEnd << [first: 'John', last: 'test'] | |
def largListWithMatchInCenter = [] | |
5000.times { largListWithMatchInCenter << [first: 'Johnx', last: 'test'] } | |
largListWithMatchInCenter << [first: 'John', last: 'test'] | |
5000.times { largListWithMatchInCenter << [first: 'Johnx', last: 'test'] } | |
def largeListWithMatchFirst = [] | |
largeListWithMatchFirst << [first: 'John', last: 'test'] | |
10000.times { largeListWithMatchFirst << [first: 'Johnx', last: 'test'] } | |
def r = benchmark { | |
'findTestWithSmallerListSize' { | |
smallList.find { it.first == 'John' } ? true : false | |
} | |
'inListTestWithSmallerListSize' { | |
'John' in smallList*.first | |
} | |
'findTestWithMatchPresentInEnd' { | |
largListWithMatchAtEnd.find { it.first == 'John' } ? true : false | |
} | |
'inListTestWithMatchPresentInEnd' { | |
'John' in largListWithMatchAtEnd*.first | |
} | |
'findTestWithMatchPresentInAverageCenter' { | |
largListWithMatchInCenter.find { it.first == 'John' } ? true : false | |
} | |
'inListTestWithMatchPresentInAverageCenter' { | |
'John' in largListWithMatchInCenter*.first | |
} | |
'findTestWithMatchPresentInFirst' { | |
largeListWithMatchFirst.find { it.first == 'John' } ? true : false | |
} | |
'inListTestWithMatchPresentInFirst' { | |
'John' in largeListWithMatchFirst*.first | |
} | |
} | |
r.prettyPrint() | |
Environment | |
=========== | |
* Groovy: 2.3.3 | |
* JVM: Java HotSpot(TM) 64-Bit Server VM (24.45-b08, Oracle Corporation) | |
* JRE: 1.7.0_45 | |
* Total Memory: 245.5 MB | |
* Maximum Memory: 2731 MB | |
* OS: Mac OS X (10.9.4, x86_64) | |
Options | |
======= | |
* Warm Up: Auto (- 60 sec) | |
* CPU Time Measurement: On | |
user system cpu real | |
findTestWithSmallerListSize 372 0 372 372 | |
inListTestWithSmallerListSize 338 0 338 338 | |
findTestWithMatchPresentInEnd 856193 380 856573 856573 | |
inListTestWithMatchPresentInEnd 853865 320 854185 854191 | |
findTestWithMatchPresentInAverageCenter 427916 474 428390 428453 | |
inListTestWithMatchPresentInAverageCenter 840076 700 840776 840776 | |
findTestWithMatchPresentInFirst 330 0 330 330 | |
inListTestWithMatchPresentInFirst 837291 1028 838319 838412 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment