Improve performance of partial

Description

This patch improves performance of partial by only using apply when needed. The code structure follows that of juxt.

Performance benchmark:

1 2 3 4 5 6 7 8 9 (ns partial-test.core (:require [criterium.core :refer [bench]]) (:gen-class)) (defn -main [] (let [f (partial + 1 1)] (println "Starting") (bench (f 1 1)) (println "Done")))

Results for 1.6.0:

1 2 3 4 5 6 7 8 9 10 Evaluation count : 228751140 in 60 samples of 3812519 calls. Execution time mean : 266.700063 ns Execution time std-deviation : 2.966851 ns Execution time lower quantile : 262.641023 ns ( 2.5%) Execution time upper quantile : 274.207916 ns (97.5%) Overhead used : 1.610513 ns Found 3 outliers in 60 samples (5.0000 %) low-severe 3 (5.0000 %) Variance from outliers : 1.6389 % Variance is slightly inflated by outliers

Results for 1.7.0 with this patch:

1 2 3 4 5 6 7 8 9 10 Evaluation count : 348208140 in 60 samples of 5803469 calls. Execution time mean : 171.210533 ns Execution time std-deviation : 2.011660 ns Execution time lower quantile : 168.819526 ns ( 2.5%) Execution time upper quantile : 176.015584 ns (97.5%) Overhead used : 2.644128 ns Found 3 outliers in 60 samples (5.0000 %) low-severe 3 (5.0000 %) Variance from outliers : 1.6389 % Variance is slightly inflated by outliers

Benchmarks performed via lein uberjar + running via the commandline.

Patch: partial-perf.diff

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

Timothy Baldridge

Labels

Approval

Ok

Patch

Code

Fix versions

Priority

Minor