X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.runtime%2Fscl%2FDebug.scl;fp=bundles%2Forg.simantics.scl.runtime%2Fscl%2FDebug.scl;h=94112010044ae102b99fa350eb0e168ef6ffcf0d;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.runtime/scl/Debug.scl b/bundles/org.simantics.scl.runtime/scl/Debug.scl new file mode 100644 index 000000000..941120100 --- /dev/null +++ b/bundles/org.simantics.scl.runtime/scl/Debug.scl @@ -0,0 +1,33 @@ +import "Prelude" +import "JavaBuiltin" as Java + +importJava "java.lang.System" where + nanoTime :: () -> Long + +""" +Executes the expression and returns the result +together with execution time in seconds. +""" +time :: ( a) -> (a,Double) +time f = do + beginTime = nanoTime () + result = f + endTime = nanoTime () + (result, Java.l2d (endTime-beginTime) * 1e-9) + +""" +Prints the given text and returns +the second parameter. +""" +trace :: String -> a -> a +trace text value = runProc do + printString text + value + +""" +Prints the given value and returns +the second parameter. +""" +traceShow :: Show a => a -> b -> b +traceShow p v = trace (show p) v +