Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Time-a-function/E/time-a-function.e
Normal file
17
Task/Time-a-function/E/time-a-function.e
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
def countTo(x) {
|
||||
println("Counting...")
|
||||
for _ in 1..x {}
|
||||
println("Done!")
|
||||
}
|
||||
|
||||
def MX := <unsafe:java.lang.management.makeManagementFactory>
|
||||
def threadMX := MX.getThreadMXBean()
|
||||
require(threadMX.isCurrentThreadCpuTimeSupported())
|
||||
threadMX.setThreadCpuTimeEnabled(true)
|
||||
|
||||
for count in [10000, 100000] {
|
||||
def start := threadMX.getCurrentThreadCpuTime()
|
||||
countTo(count)
|
||||
def finish := threadMX.getCurrentThreadCpuTime()
|
||||
println(`Counting to $count takes ${(finish-start)//1000000}ms`)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue