Mercurial > urweb
changeset 2290:ab6ca12debeb
Add small benchmark (WIP).
author | ziv@mit.edu |
---|---|
date | Sun, 15 Nov 2015 18:10:24 -0500 |
parents | 78820fa8f5a7 |
children | 50ad02829abd |
files | caching-tests/bench.ur caching-tests/bench.urp caching-tests/bench.urs caching-tests/test.urp |
diffstat | 4 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/caching-tests/bench.ur Sun Nov 15 18:10:24 2015 -0500 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/caching-tests/bench.urp Sun Nov 15 18:10:24 2015 -0500 @@ -0,0 +1,5 @@ +database host=localhost +sql bench.sql +safeGet Bench/main + +bench