Skip to content

Commit

Permalink
Merge pull request #16 from janetacarr/retrieve-speedup
Browse files Browse the repository at this point in the history
CLJS benchmark macro & README update
  • Loading branch information
janetacarr authored Jan 19, 2024
2 parents 6145c94 + 16abbdd commit 6212370
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 228 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ user> (-> (->bounds 0 0 800 600)
user>
```

Oh, and quadtree-cljc is fast:

``` clojure
;; Benched with criterium on JDK21/M2 Max MBP
user> (let [entities (generate-entities ->random-large-entity 1000)
player (->random-small-entity)]
(bench/bench (-> (->bounds 0 0 1920 1080)
(->quadtree 1020 100)
(insert-all entities)
(retrieve-intersections player))))

Evaluation count : 155640 in 60 samples of 2594 calls.
Execution time mean : 389.595233 µs
Execution time std-deviation : 2.873750 µs
Execution time lower quantile : 383.609006 µs ( 2.5%)
Execution time upper quantile : 393.246808 µs (97.5%)
Overhead used : 1.666329 ns

Found 1 outliers in 60 samples (1.6667 %)
low-severe 1 (1.6667 %)
Variance from outliers : 1.6389 % Variance is slightly inflated by outliers
nil
```


If you were using this in a game, you might build up your quadtree on every game frame,
inserting all your entities bounds, and then decide if you should update your entities.

Expand Down
3 changes: 1 addition & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{:paths ["src"
"test"]
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.10.764"}}
:aliases {:build {:deps {slipset/deps-deploy {:mvn/version "0.2.0"}
Expand Down
Loading

0 comments on commit 6212370

Please sign in to comment.