Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,12 @@
import java.lang.management.ManagementFactory
import java.lang.management.ThreadMXBean
def threadMX = ManagementFactory.threadMXBean
assert threadMX.currentThreadCpuTimeSupported
threadMX.threadCpuTimeEnabled = true
def clockCpuTime = { Closure c ->
def start = threadMX.currentThreadCpuTime
c.call()
(threadMX.currentThreadCpuTime - start)/1000000
}

View file

@ -0,0 +1,5 @@
def clockRealTime = { Closure c ->
def start = System.currentTimeMillis()
c.call()
System.currentTimeMillis() - start
}

View file

@ -0,0 +1,11 @@
def countTo = { Long n ->
long i = 0; while(i < n) { i += 1L }
}
["CPU time":clockCpuTime, "wall clock time":clockRealTime].each { measurementType, timer ->
println '\n'
[100000000L, 1000000000L].each { testSize ->
def measuredTime = timer(countTo.curry(testSize))
println "Counting to ${testSize} takes ${measuredTime}ms of ${measurementType}"
}
}