Created
December 1, 2023 21:36
-
-
Save thospfuller/a2a6bf7e033163d8f99e6c42bf77ffd7 to your computer and use it in GitHub Desktop.
An example regarding how to add elements to a List in Java.
This file contains 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='com.jamonapi', module='jamon', version='2.82') | |
import com.jamonapi.Monitor | |
import com.jamonapi.MonitorFactory | |
import java.util.List | |
import java.util.UUID | |
import static java.util.Arrays.asList | |
def arrayCapacity = 10000 | |
def uuids = new String[arrayCapacity + 1] | |
for (int ctr in 0..arrayCapacity) | |
uuids[ctr] = UUID.randomUUID().toString () | |
def uuidList = asList (uuids) | |
def iterations = 100000 | |
def monitor = MonitorFactory.start("Convert an array to an ArrayList performance monitor via the LinkedList constructor example") | |
for (ctr in 0..iterations) { | |
def exampleList = new LinkedList (uuidList) as java.util.List | |
} | |
monitor.stop () | |
println "iterations: $iterations, performance: $monitor" | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment