From 9e58f93cc93fba2ed016555a63788f828d7d8ffe Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Mon, 14 Jan 2019 20:41:58 +0200 Subject: [PATCH] test all calfpath perf --- perf-test/clj/reitit/opensensors_perf_test.clj | 17 ++++++++++++----- test/cljc/reitit/core_test.cljc | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/perf-test/clj/reitit/opensensors_perf_test.clj b/perf-test/clj/reitit/opensensors_perf_test.clj index ba8c3813..b53c2b09 100644 --- a/perf-test/clj/reitit/opensensors_perf_test.clj +++ b/perf-test/clj/reitit/opensensors_perf_test.clj @@ -489,9 +489,12 @@ {:uri "/v1/users/:user-id/bookmarks" :nested [{:method :get, :handler handler}]} {:uri "/v1/orgs/:org-id/topics" :nested [{:method :get, :handler handler}]}]) -(def opensensors-calfpath-data-handler +(def opensensors-calfpath-walker-handler (partial cr/dispatch (cr/compile-routes opensensors-calfpath-routes {:show-uris-400? false}))) +(def opensensors-calfpath-unroll-handler + (cr/make-dispatcher (cr/compile-routes opensensors-calfpath-routes {:show-uris-400? false}))) + (comment (pedestal/find-route (map-tree/router @@ -551,7 +554,8 @@ reitit-ring-fast-f (ring/ring-handler (ring/router opensensors-routes) nil {:inject-router? false, :inject-match? false}) bidi-f #(bidi/match-route opensensors-bidi-routes (:uri %)) calfpath-macros-f opensensors-calfpath-macro-handler - calfpath-data-f opensensors-calfpath-data-handler + calfpath-walker-f opensensors-calfpath-walker-handler + calfpath-unroll-f opensensors-calfpath-unroll-handler ataraxy-f (partial ataraxy/matches opensensors-ataraxy-routes) compojure-f opensensors-compojure-routes pedestal-f (partial pedestal/find-route opensensors-pedestal-routes) @@ -577,13 +581,16 @@ ;; 385ns (java-segment-router, no injects) (b! "reitit-ring-fast" reitit-ring-fast-f) - ;; 2258ns - (b! "calfpath-data" calfpath-data-f) + ;; 2137ns + (b! "calfpath-walker" calfpath-walker-f) + + ;; 4774ns + (b! "calfpath-unroll" calfpath-unroll-f) ;; 2821ns (b! "pedestal" pedestal-f) - ;; 4364ns + ;; 4803ns (b! "calfpath-macros" calfpath-macros-f) ;; 11615ns diff --git a/test/cljc/reitit/core_test.cljc b/test/cljc/reitit/core_test.cljc index c64525e8..a5d5b1e9 100644 --- a/test/cljc/reitit/core_test.cljc +++ b/test/cljc/reitit/core_test.cljc @@ -17,6 +17,8 @@ (is (= [["/api/ipa/:size" {:name ::beer}]] (r/routes router))) (is (map? (r/options router))) + (is (= nil + (r/match-by-path router "/api"))) (is (= (r/map->Match {:template "/api/ipa/:size" :data {:name ::beer} @@ -108,6 +110,8 @@ (is (= [["/api/ipa/large" {:name ::beer}]] (r/routes router))) (is (map? (r/options router))) + (is (= nil + (r/match-by-path router "/api"))) (is (= (r/map->Match {:template "/api/ipa/large" :data {:name ::beer}