mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Add bench code and update all scripts.
This commit is contained in:
parent
5ae1c6a78c
commit
c419e9406b
13 changed files with 123 additions and 7 deletions
78
dev/bench/core.cljs
Normal file
78
dev/bench/core.cljs
Normal file
|
@ -0,0 +1,78 @@
|
|||
(ns bench.core
|
||||
(:require [kdtree :as k]))
|
||||
|
||||
(enable-console-print!)
|
||||
|
||||
(defn generate-points
|
||||
[n]
|
||||
(for [x (range 0 n)
|
||||
y (range 0 n)]
|
||||
(k/point2d x y)))
|
||||
|
||||
(defn bench-init-100
|
||||
[]
|
||||
(let [points (into-array (generate-points 10))]
|
||||
(time
|
||||
(k/create2d points))))
|
||||
|
||||
(defn bench-init-1000
|
||||
[]
|
||||
(let [points (into-array (generate-points 100))]
|
||||
(time
|
||||
(k/create2d points))))
|
||||
|
||||
(defn bench-init-10000
|
||||
[]
|
||||
(let [points (into-array (generate-points 1000))]
|
||||
(time
|
||||
(k/create2d points))))
|
||||
|
||||
(defn bench-init
|
||||
[]
|
||||
(println "init:100")
|
||||
(bench-init-100)
|
||||
(println "init:1000")
|
||||
(bench-init-1000)
|
||||
(println "init:10000")
|
||||
(bench-init-10000))
|
||||
|
||||
(defn bench-knn-100000-2
|
||||
[]
|
||||
(let [tree (-> (into-array (generate-points 10000))
|
||||
(k/create2d points))
|
||||
pt (k/point2d (rand-int 10000)
|
||||
(rand-int 10000))]
|
||||
|
||||
(dotimes [i 100]
|
||||
(time
|
||||
(.nearest tree pt 2)))))
|
||||
|
||||
(defn bench-knn-10000-2
|
||||
[]
|
||||
(let [tree (-> (into-array (generate-points 1000))
|
||||
(k/create2d points))
|
||||
pt (k/point2d (rand-int 1000)
|
||||
(rand-int 1000))]
|
||||
|
||||
(dotimes [i 100]
|
||||
(time
|
||||
(.nearest tree pt 2)))))
|
||||
|
||||
(defn bench-knn
|
||||
[]
|
||||
(println "knn:10000:2")
|
||||
(bench-knn-10000-2))
|
||||
|
||||
(defn main
|
||||
[& [type]]
|
||||
(cond
|
||||
(= type "init")
|
||||
(bench-init)
|
||||
|
||||
(= type "knn")
|
||||
(bench-knn)
|
||||
|
||||
:else
|
||||
(println "not implemented")))
|
||||
|
||||
(set! *main-cli-fn* main)
|
|
@ -4,6 +4,11 @@
|
|||
:license {:name "MPL 2.0" :url "https://www.mozilla.org/en-US/MPL/2.0/"}
|
||||
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]
|
||||
|
||||
:source-paths ["src" "vendor"]
|
||||
:test-paths ["test"]
|
||||
|
||||
:profiles {:dev {:source-paths ["dev"]}}
|
||||
|
||||
:dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
|
||||
[org.clojure/clojurescript "1.8.40" :scope "provided"]
|
||||
[figwheel-sidecar "0.5.2" :scope "test"]
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
lein trampoline run -m clojure.main scripts/build.clj
|
2
scripts/build-bench
Executable file
2
scripts/build-bench
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
lein trampoline run -m clojure.main scripts/build-bench.clj
|
13
scripts/build-bench.clj
Normal file
13
scripts/build-bench.clj
Normal file
|
@ -0,0 +1,13 @@
|
|||
(require '[cljs.build.api :as b])
|
||||
|
||||
(b/build
|
||||
(b/inputs "vendor" "dev")
|
||||
{:main 'bench.core
|
||||
:output-to "out/bench.js"
|
||||
:output-dir "out"
|
||||
:parallel-build false
|
||||
:optimizations :simple
|
||||
:language-in :ecmascript5
|
||||
:language-out :ecmascript5
|
||||
:target :nodejs
|
||||
:verbose true})
|
2
scripts/build-tests
Executable file
2
scripts/build-tests
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
lein trampoline run -m clojure.main scripts/build-tests.clj
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
(let [start (System/nanoTime)]
|
||||
(b/build
|
||||
(b/inputs "src" "test")
|
||||
(b/inputs "src" "vendor" "test")
|
||||
{:main 'uxbox.test-runner
|
||||
:output-to "out/tests.js"
|
||||
:output-dir "out"
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
(let [start (System/nanoTime)]
|
||||
(b/build
|
||||
(b/inputs "src")
|
||||
(b/inputs "src" "vendor")
|
||||
{:main 'uxbox.core
|
||||
:parallel-build false
|
||||
:warnings {:ns-var-clash false}
|
||||
|
|
|
@ -11,13 +11,15 @@
|
|||
:all-builds
|
||||
[{:id "dev"
|
||||
:figwheel {:on-jsload "uxbox.ui/init"}
|
||||
:source-paths ["src"]
|
||||
:source-paths ["src" "vendor"]
|
||||
:compiler {:main 'uxbox.core
|
||||
:asset-path "js"
|
||||
:parallel-build false
|
||||
:optimizations :none
|
||||
;; :closure-defines {"uxbox.repo.core.url"
|
||||
;; "https://test.uxbox.io/api"}
|
||||
:closure-defines {"uxbox.repo.core.url"
|
||||
"https://test.uxbox.io/api"}
|
||||
"http://localhost:6060/api"}
|
||||
:warnings {:ns-var-clash false}
|
||||
:pretty-print true
|
||||
:language-in :ecmascript5
|
||||
|
|
2
scripts/watch-bench
Executable file
2
scripts/watch-bench
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
lein trampoline run -m clojure.main scripts/watch-bench.clj
|
14
scripts/watch-bench.clj
Normal file
14
scripts/watch-bench.clj
Normal file
|
@ -0,0 +1,14 @@
|
|||
(require '[cljs.build.api :as b])
|
||||
|
||||
(b/watch
|
||||
(b/inputs "vendor" "dev")
|
||||
{:main 'bench.core
|
||||
:output-to "out/bench.js"
|
||||
:output-dir "out"
|
||||
:parallel-build false
|
||||
:optimizations :simple
|
||||
:pretty-print true
|
||||
:target :nodejs
|
||||
:language-in :ecmascript6
|
||||
:language-out :ecmascript5
|
||||
:verbose true})
|
|
@ -4,7 +4,7 @@
|
|||
(alter-var-root #'cljs.tagged-literals/*cljs-data-readers*
|
||||
assoc 'ux/tr (fn [v] `(uxbox.locales/tr ~v)))
|
||||
|
||||
(b/watch (b/inputs "src" "test")
|
||||
(b/watch (b/inputs "src" "vendor" "test")
|
||||
{:main 'uxbox.test-runner
|
||||
:output-to "out/tests.js"
|
||||
:output-dir "out"
|
Loading…
Reference in a new issue