]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/scl/Debug.scl
Fixed incorrect interaction of EAmbigious and TMetaVar.setRef
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Debug.scl
1 import "Prelude"
2 import "JavaBuiltin" as Java
3
4 importJava "java.lang.System" where
5     nanoTime :: () -> <Proc> Long
6
7 """
8 Executes the expression and returns the result
9 together with execution time in seconds.
10 """
11 time :: (<e> a) -> <Proc,e> (a,Double)
12 time f = do
13     beginTime = nanoTime ()
14     result = f
15     endTime = nanoTime ()
16     (result, Java.l2d (endTime-beginTime) * 1e-9)
17
18 reportTime :: (<e> a) -> <e> a
19 reportTime f = runProc do
20     beginTime = nanoTime ()
21     result = f
22     endTime = nanoTime ()
23     time = Java.l2d (endTime-beginTime) * 1e-9
24     print "time \(time) s"
25     result
26
27 """
28 Prints the given text and returns
29 the second parameter.
30 """
31 trace :: String -> a -> a
32 trace text value = runProc do
33     printString text
34     value
35
36 """
37 Prints the given value and returns
38 the second parameter.
39 """
40 traceShow :: Show a => a -> b -> b
41 traceShow p v = trace (show p) v
42