comparison caching-tests/bench.ur @ 2290:ab6ca12debeb

Add small benchmark (WIP).
author ziv@mit.edu
date Sun, 15 Nov 2015 18:10:24 -0500
parents
children 23eaec04e0f8
comparison
equal deleted inserted replaced
2289:78820fa8f5a7 2290:ab6ca12debeb
1 table tab : {Id : int, Val : int} PRIMARY KEY Id
2
3 fun check id =
4 res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]});
5 return <xml><body>
6 {case res of
7 None => <xml>?</xml>
8 | Some row => <xml>{[row.Tab.Val]}</xml>}
9 </body></xml>
10
11 fun flush id =
12 dml (UPDATE tab SET Val = Val + 1 WHERE Id = {[id]});
13 return <xml><body>
14 Changed {[id]}!
15 </body></xml>
16
17 fun main x y =
18 r <- rand;
19 let
20 val id = r % x
21 val doFlush = (r / x) % y = 0
22 in
23 if doFlush then flush id else check id
24 end