2019-06-05 03:26:05 -05:00
|
|
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
;;
|
2022-09-20 16:23:22 -05:00
|
|
|
;; Copyright (c) KALEIDOS INC
|
2019-06-05 03:26:05 -05:00
|
|
|
|
|
|
|
(ns user
|
2019-11-18 05:52:57 -05:00
|
|
|
(:require
|
2022-02-07 06:00:26 -05:00
|
|
|
[app.common.data :as d]
|
2024-01-30 07:22:56 -05:00
|
|
|
[app.common.debug :as debug]
|
2021-02-15 07:14:05 -05:00
|
|
|
[app.common.exceptions :as ex]
|
2024-01-03 09:16:14 -05:00
|
|
|
[app.common.files.helpers :as cfh]
|
2023-05-19 12:37:53 -05:00
|
|
|
[app.common.fressian :as fres]
|
2022-01-12 14:23:25 -05:00
|
|
|
[app.common.geom.matrix :as gmt]
|
2022-09-28 16:26:31 -05:00
|
|
|
[app.common.logging :as l]
|
2022-01-12 14:23:25 -05:00
|
|
|
[app.common.perf :as perf]
|
2022-09-06 09:52:51 -05:00
|
|
|
[app.common.pprint :as pp]
|
2023-05-19 12:37:53 -05:00
|
|
|
[app.common.schema :as sm]
|
|
|
|
[app.common.schema.desc-js-like :as smdj]
|
|
|
|
[app.common.schema.desc-native :as smdn]
|
|
|
|
[app.common.schema.generators :as sg]
|
2022-11-28 10:47:27 -05:00
|
|
|
[app.common.spec :as us]
|
2024-08-16 05:01:00 -05:00
|
|
|
[app.common.json :as json]
|
2022-01-12 14:23:25 -05:00
|
|
|
[app.common.transit :as t]
|
2023-07-27 17:18:38 -05:00
|
|
|
[app.common.types.file :as ctf]
|
2022-10-06 10:03:36 -05:00
|
|
|
[app.common.uuid :as uuid]
|
2023-10-23 12:31:41 -05:00
|
|
|
[app.config :as cf]
|
2023-11-30 07:08:41 -05:00
|
|
|
[app.db :as db]
|
2020-12-24 08:32:19 -05:00
|
|
|
[app.main :as main]
|
2023-07-27 17:18:38 -05:00
|
|
|
[app.srepl.helpers :as srepl.helpers]
|
2022-10-06 10:03:36 -05:00
|
|
|
[app.srepl.main :as srepl]
|
2021-03-08 07:14:52 -05:00
|
|
|
[app.util.blob :as blob]
|
2020-12-24 08:32:19 -05:00
|
|
|
[app.util.time :as dt]
|
2022-01-12 14:23:25 -05:00
|
|
|
[clj-async-profiler.core :as prof]
|
|
|
|
[clojure.contrib.humanize :as hum]
|
2020-12-24 08:32:19 -05:00
|
|
|
[clojure.java.io :as io]
|
2021-03-08 07:14:52 -05:00
|
|
|
[clojure.pprint :refer [pprint print-table]]
|
2020-12-24 08:32:19 -05:00
|
|
|
[clojure.repl :refer :all]
|
2019-11-26 07:34:37 -05:00
|
|
|
[clojure.spec.alpha :as s]
|
2022-11-28 10:47:27 -05:00
|
|
|
[clojure.stacktrace :as trace]
|
2020-12-24 08:32:19 -05:00
|
|
|
[clojure.test :as test]
|
2023-03-18 04:32:26 -05:00
|
|
|
[clojure.test.check.generators :as tgen]
|
2019-11-18 05:52:57 -05:00
|
|
|
[clojure.tools.namespace.repl :as repl]
|
|
|
|
[clojure.walk :refer [macroexpand-all]]
|
2022-10-06 10:03:36 -05:00
|
|
|
[criterium.core :as crit]
|
2022-11-28 10:47:27 -05:00
|
|
|
[cuerdas.core :as str]
|
2024-02-14 03:31:59 -05:00
|
|
|
[datoteka.fs :as fs]
|
2023-05-19 12:37:53 -05:00
|
|
|
[integrant.core :as ig]
|
|
|
|
[malli.core :as m]
|
|
|
|
[malli.dev.pretty :as mdp]
|
|
|
|
[malli.error :as me]
|
|
|
|
[malli.generator :as mg]
|
|
|
|
[malli.registry :as mr]
|
|
|
|
[malli.transform :as mt]
|
2023-07-27 17:18:38 -05:00
|
|
|
[malli.util :as mu]
|
|
|
|
[promesa.exec :as px]))
|
2020-12-24 08:32:19 -05:00
|
|
|
|
|
|
|
(repl/disable-reload! (find-ns 'integrant.core))
|
2024-01-30 07:22:56 -05:00
|
|
|
(repl/disable-reload! (find-ns 'app.common.debug))
|
|
|
|
|
2021-12-21 09:25:21 -05:00
|
|
|
(set! *warn-on-reflection* true)
|
2020-12-24 08:32:19 -05:00
|
|
|
|
2024-01-30 07:22:56 -05:00
|
|
|
(add-tap #'debug/tap-handler)
|
|
|
|
|
2022-09-06 09:52:51 -05:00
|
|
|
;; --- Benchmarking Tools
|
|
|
|
|
|
|
|
(defmacro run-quick-bench
|
|
|
|
[& exprs]
|
2022-10-06 10:03:36 -05:00
|
|
|
`(crit/with-progress-reporting (crit/quick-bench (do ~@exprs) :verbose)))
|
2022-09-06 09:52:51 -05:00
|
|
|
|
|
|
|
(defmacro run-quick-bench'
|
|
|
|
[& exprs]
|
2022-10-06 10:03:36 -05:00
|
|
|
`(crit/quick-bench (do ~@exprs)))
|
2022-09-06 09:52:51 -05:00
|
|
|
|
|
|
|
(defmacro run-bench
|
|
|
|
[& exprs]
|
2022-10-06 10:03:36 -05:00
|
|
|
`(crit/with-progress-reporting (crit/bench (do ~@exprs) :verbose)))
|
2022-09-06 09:52:51 -05:00
|
|
|
|
|
|
|
(defmacro run-bench'
|
|
|
|
[& exprs]
|
2022-10-06 10:03:36 -05:00
|
|
|
`(crit/bench (do ~@exprs)))
|
2022-09-06 09:52:51 -05:00
|
|
|
|
2019-06-05 03:26:05 -05:00
|
|
|
;; --- Development Stuff
|
|
|
|
|
2020-01-13 09:14:29 -05:00
|
|
|
(defn- run-tests
|
2022-11-08 04:40:19 -05:00
|
|
|
([] (run-tests #"^backend-tests.*-test$"))
|
2019-06-05 03:26:05 -05:00
|
|
|
([o]
|
2020-02-03 16:29:59 -05:00
|
|
|
(repl/refresh)
|
2019-06-05 03:26:05 -05:00
|
|
|
(cond
|
|
|
|
(instance? java.util.regex.Pattern o)
|
|
|
|
(test/run-all-tests o)
|
|
|
|
|
|
|
|
(symbol? o)
|
|
|
|
(if-let [sns (namespace o)]
|
|
|
|
(do (require (symbol sns))
|
|
|
|
(test/test-vars [(resolve o)]))
|
|
|
|
(test/test-ns o)))))
|
2020-02-24 09:29:12 -05:00
|
|
|
|
2020-12-24 08:32:19 -05:00
|
|
|
(defn- start
|
|
|
|
[]
|
2022-11-28 10:47:27 -05:00
|
|
|
(try
|
2023-11-15 07:35:34 -05:00
|
|
|
(main/start)
|
2022-11-28 10:47:27 -05:00
|
|
|
:started
|
|
|
|
(catch Throwable cause
|
|
|
|
(ex/print-throwable cause))))
|
2020-12-24 08:32:19 -05:00
|
|
|
|
|
|
|
(defn- stop
|
|
|
|
[]
|
2023-11-15 07:35:34 -05:00
|
|
|
(main/stop)
|
2022-10-04 08:03:08 -05:00
|
|
|
:stopped)
|
2020-12-24 08:32:19 -05:00
|
|
|
|
|
|
|
(defn restart
|
|
|
|
[]
|
|
|
|
(stop)
|
|
|
|
(repl/refresh :after 'user/start))
|
|
|
|
|
|
|
|
(defn restart-all
|
|
|
|
[]
|
|
|
|
(stop)
|
|
|
|
(repl/refresh-all :after 'user/start))
|
2021-03-08 07:14:52 -05:00
|
|
|
|
2023-11-10 18:13:01 -05:00
|
|
|
;; (defn compression-bench
|
|
|
|
;; [data]
|
|
|
|
;; (let [humanize (fn [v] (hum/filesize v :binary true :format " %.4f "))
|
|
|
|
;; v1 (time (humanize (alength (blob/encode data {:version 1}))))
|
|
|
|
;; v3 (time (humanize (alength (blob/encode data {:version 3}))))
|
|
|
|
;; v4 (time (humanize (alength (blob/encode data {:version 4}))))
|
|
|
|
;; v5 (time (humanize (alength (blob/encode data {:version 5}))))
|
|
|
|
;; v6 (time (humanize (alength (blob/encode data {:version 6}))))
|
|
|
|
;; ]
|
|
|
|
;; (print-table
|
|
|
|
;; [{
|
|
|
|
;; :v1 v1
|
|
|
|
;; :v3 v3
|
|
|
|
;; :v4 v4
|
|
|
|
;; :v5 v5
|
|
|
|
;; :v6 v6
|
|
|
|
;; }])))
|
2021-12-21 09:25:21 -05:00
|
|
|
|
2024-01-03 09:16:14 -05:00
|
|
|
(defn calculate-frames
|
|
|
|
[{:keys [data]}]
|
|
|
|
(->> (vals (:pages-index data))
|
|
|
|
(mapcat (comp vals :objects))
|
|
|
|
(filter cfh/is-direct-child-of-root?)
|
|
|
|
(filter cfh/frame-shape?)
|
|
|
|
(count)))
|