Created
May 17, 2020 03:15
-
-
Save EmmanuelOga/0ca240eee458fb8e039c5089c43d904a to your computer and use it in GitHub Desktop.
This file contains 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
(ns minibench.core | |
(:import | |
java.util.Random | |
[org.basex BaseXServer] | |
[org.basex.api.client ClientSession])) | |
(defonce server (BaseXServer. (make-array String 0))) | |
(def running (atom true)) | |
(def r (Random.)) | |
(defn launch-bg | |
[query] | |
(doto | |
(Thread. | |
(fn [] | |
(with-open [session (ClientSession. "localhost", 1984, "admin", "admin")] | |
(.execute session (str "OPEN input")) | |
(while @running | |
(println "Executing " query) | |
(.execute session (str "XQUERY " query)) | |
(Thread/sleep (.nextInt r 500)))))) | |
(.start))) | |
(let [input "c:/Users/emman/workspace/vendor/basex/basex-examples/src/main/resources/xml/input.xml"] | |
(with-open [session (ClientSession. "localhost", 1984, "admin", "admin")] | |
(.execute session (str "CREATE DB input " input)) | |
(println | |
"START: " | |
(.execute session (str "XQUERY //li"))) | |
(reset! running true) | |
(launch-bg "//li") | |
(launch-bg "insert node <li>new node</li> as last into /html/body//ul") | |
(launch-bg "insert node <new>One more</new> as last into /html/body") | |
(Thread/sleep 10000) | |
(reset! running false) | |
(println | |
"END: " | |
(.execute session (str "XQUERY //li"))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment