isbpl/time.isbpl

47 lines
709 B
Text

native time
func getms {
0 time
}
func sleep {
time pop
}
func delay {
time pop
}
func delays {
1000 * time pop
}
def Timer
construct Timer {
startMS
stopMS
timeTakenTMP
;
start {
with this ;
getms this =startMS
null this =timeTakenTMP
}
end {
with this ;
getms this =stopMS
null this =timeTakenTMP
}
timeTaken {
with this ;
this timeTakenTMP null eq not if {
this timeTakenTMP 2 stop
}
this startMS this stopMS eq if {
0 dup this =timeTakenTMP
2 stop
}
this stopMS this startMS - dup this =timeTakenTMP
}
} =Timer