mirror of https://github.com/logseq/logseq
chore: query performance: enlarge test timeout and add dev doc
parent
a1c60fa58c
commit
f45317e569
|
@ -149,6 +149,17 @@ To write a test that uses a datascript db:
|
|||
* The easiest way to set up test data is to use `test-helper/load-test-files`.
|
||||
* For the repo argument that most fns take, pass it `test-helper/test-db`
|
||||
|
||||
#### Performance tests
|
||||
To write a performance test:
|
||||
|
||||
* Use `frontend.util/with-time-number` to get the time in ms.
|
||||
|
||||
* Example:
|
||||
```clojure
|
||||
(are [x timeout] (>= timeout (:time (util/with-time-number (block/normalize-block x true))))
|
||||
... )
|
||||
```
|
||||
|
||||
For examples of these tests, see `frontend.db.query-dsl-test` and `frontend.db.model-test`.
|
||||
|
||||
### Async Unit Testing
|
||||
|
|
|
@ -70,16 +70,16 @@
|
|||
[{:title "意志"} {:title "圆圈"}])
|
||||
(state/set-preferred-language! "en"))
|
||||
|
||||
(testing "monitor sort time"
|
||||
(testing "monitor time of sort by integer block property"
|
||||
(are [sort-state result _sorted-result timeout]
|
||||
(>= timeout (:time (util/with-time-number (#'query-table/sort-result (mapv #(hash-map :block/properties %) result) sort-state))))
|
||||
{:sort-desc? true :sort-by-column :rating}
|
||||
[{:rating 8} {:rating 7}]
|
||||
[{:rating 8} {:rating 7}]
|
||||
0.1 ;; actual: ~0.05
|
||||
0.5 ;; actual: ~0.05
|
||||
|
||||
{:sort-desc? false :sort-by-column :rating}
|
||||
[{:rating 8} {:rating 7}]
|
||||
[{:rating 7} {:rating 8}]
|
||||
0.2 ;; actual: ~0.05
|
||||
0.5 ;; actual: ~0.05
|
||||
)))
|
||||
|
|
Loading…
Reference in New Issue