-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestingBin.idr
76 lines (57 loc) · 2.33 KB
/
testingBin.idr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import LinearLibPoly9
import HelpfulLinear
import Control.Linear.LIO
import Prelude.Num
import Data.Fin
import Data.Nat
import System
import System.Clock
import Data.Vect
import BinarySearchFinal
%foreign "C:writeNums, arrayWrite"
writeNums : AnyPtr -> Int -> PrimIO (AnyPtr)
doUpdate' : (IntArray (S size) isParent self) -> L IO {use=1} (IntArray (S size) isParent self)
doUpdate' arr = let (s, ptr) = getPointerUnsafe arr in do
_ <- liftIO1 {io=L IO} $ fromPrim $ writeNums ptr (cast s)
pure1 arr
doUpdate : (1 _ : IntArray (S size) isParent self) -> L IO {use=1} (IntArray (S size) isParent self)
doUpdate = assert_linear doUpdate'
nano : Integer
nano = 1000000000
f : Nat -> Nat
f x = x
{-
main : IO ()
main = do
myList <- getArgs
case myList of
[_, a] => (runLin $ do
let y = f (cast a)
clock <- liftIO1 {io = L IO} $ clockTime Process
let t = seconds clock * nano + nanoseconds clock
clock <- liftIO1 {io = L IO} (clockTime Process)
let t' = seconds clock * nano + nanoseconds clock
let time = t' - t
print time
)
_ => print "not right arguments"
-}
-- Need to try integers to give it a chance I think, god knows
main : IO ()
main = do
myList <- getArgs
case myList of
[_, a] => (runLin $ do
let y = S (cast a)
_ # arr <- createIntArray y
arr <- doUpdate arr
clock <- liftIO1 {io = L IO} $ clockTime Process
val *? arr <- binSearch 0 arr
clock' <- liftIO1 {io = L IO} (clockTime Process)
let t = seconds clock * nano + nanoseconds clock
let t' = seconds clock' * nano + nanoseconds clock'
let time = t' - t
freeIntArray arr
print time
)
_ => print "not right arguments"