Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga

EmmanuelOga/core.clj

Created May 17, 2020
Embed
What would you like to do?
(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