summaryrefslogtreecommitdiff
path: root/caching-tests/bench.ur
diff options
context:
space:
mode:
authorGravatar ziv <ziv@mit.edu>2015-11-15 18:10:24 -0500
committerGravatar ziv <ziv@mit.edu>2015-11-15 18:10:24 -0500
commit96537889753c222279e3937495dbc56054b377b9 (patch)
treef827eebda9bd4ae367a3690d57f313342a839797 /caching-tests/bench.ur
parented7b5e6f956c5b13735cc3e5c4de01fbfc437e12 (diff)
Add small benchmark (WIP).
Diffstat (limited to 'caching-tests/bench.ur')
-rw-r--r--caching-tests/bench.ur24
1 files changed, 24 insertions, 0 deletions
diff --git a/caching-tests/bench.ur b/caching-tests/bench.ur
new file mode 100644
index 00000000..0c7bb674
--- /dev/null
+++ b/caching-tests/bench.ur
@@ -0,0 +1,24 @@
+table tab : {Id : int, Val : int} PRIMARY KEY Id
+
+fun check id =
+ res <- oneOrNoRows (SELECT tab.Val FROM tab WHERE tab.Id = {[id]});
+ return <xml><body>
+ {case res of
+ None => <xml>?</xml>
+ | Some row => <xml>{[row.Tab.Val]}</xml>}
+ </body></xml>
+
+fun flush id =
+ dml (UPDATE tab SET Val = Val + 1 WHERE Id = {[id]});
+ return <xml><body>
+ Changed {[id]}!
+ </body></xml>
+
+fun main x y =
+ r <- rand;
+ let
+ val id = r % x
+ val doFlush = (r / x) % y = 0
+ in
+ if doFlush then flush id else check id
+ end