Last active
December 22, 2015 11:19
-
-
Save apb2006/6464619 to your computer and use it in GitHub Desktop.
timeout test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let $s:=" | |
import module namespace test = 'org.apb.modules.TestModule'; | |
declare function local:prime($n){ | |
$n = 2 or ($n > 2 and | |
(every $d in 2 to xs:integer(math:sqrt($n)) satisfies $n mod $d > 0)) | |
}; | |
let $t:=test:startTimeout(xs:int(10000)) | |
return count((1 to 1000000)[local:prime(.)]) | |
" | |
let $c := client:connect('localhost', 1984, 'admin', 'admin') | |
return client:query($c,$s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare function local:timeit($label,$exp,$timeout){ | |
let $c := client:connect('localhost', 1984, 'admin', 'admin') | |
let $s:=prof:current-ms() | |
let $result:=try{ | |
let $c:=client:query($c,$exp,map{'TIMEOUT':=$timeout}) | |
return () | |
}catch * { | |
$err:code | |
} | |
return <exec label="{$label}" time="{prof:current-ms()-$s}" result="{$result}"/> | |
}; | |
let $s:="import module namespace test = 'org.apb.modules.TestModule'; | |
declare function local:prime($n){ | |
$n = 2 or ($n > 2 and | |
(every $d in 2 to $n idiv 2 satisfies $n mod $d > 0)) | |
}; | |
let $t:=test:startTimeout(xs:int($TIMEOUT)) | |
return count((1 to 100000)[local:prime(.)])" | |
return local:timeit("prime",$s,20000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import module namespace test = 'org.apb.modules.TestModule'; | |
declare function local:prime($n){ | |
$n = 2 or ($n > 2 and | |
(every $d in 2 to xs:integer(math:sqrt($n)) satisfies $n mod $d > 0)) | |
}; | |
let $t:=test:setTimeout(xs:int(5000)) | |
return count((1 to 1000000)[local:prime(.)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment