Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Created May 17, 2020 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmmanuelOga/0ca240eee458fb8e039c5089c43d904a to your computer and use it in GitHub Desktop.
Save EmmanuelOga/0ca240eee458fb8e039c5089c43d904a to your computer and use it in GitHub Desktop.
(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