Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thospfuller/a2a6bf7e033163d8f99e6c42bf77ffd7 to your computer and use it in GitHub Desktop.
Save thospfuller/a2a6bf7e033163d8f99e6c42bf77ffd7 to your computer and use it in GitHub Desktop.
An example regarding how to add elements to a List in Java.
@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