Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

The attached patch simplifies and speeds up the RangedIterator.

The benchmarks were run using the following function to test vector iteration:

`
(defn consume-iterator
[v]
(let [iter (-iterator v)]

(loop []
  (when (.hasNext iter)
    (.next iter)
    (recur)))))

`

A series of "simple-benchmarks" were setup as follows:

(simple-benchmark [v (into [] (range N))] (consume-iterator v) I)

Where 'N' and 'I' were values from the 'Vector Size' and 'Iterations' columns of the table below .

|Vector Size|Iterations|V8 Speed (link: msec) (master)|V8 Speed (link: msec) (patch)|JSC Speed (link: msec) (master)| JSC Speed (link: msec) (patch)|
| :-- | :-- | :-- | :-- | :-- | :-- | :-- |
|1|100,000|15|11|13|7|
|2|100,000|14|10|7|4|
|4|100,000|18|10|9|5|
|8|100,000|27|12|14|6|
|16|100,000|43|17|19|9|
|32|100,000|74|24|37|15|
|100|100,000|217|59|105|45|
|1000|100,000|2008|524|1032|392|
|10,000|100,000|20390|5856|10249|4178|
|100,000|10,000|20334|5324|10324|4387|

Javascript engine versions used:
V8 version 5.1.281.47
JSC version Unknown

The RangedIterator constructor function ranged-iterator was also made private.

7 Answers

0 votes
by

Comment made by: dnolen

Let's get a patch with the performance change without altering the constructor first. Thanks.

0 votes
by

Comment made by: tmulvaney

Rebased and constructor no longer private.

0 votes
by

Comment made by: dnolen

Sorry for not being clear. Leave the fields of the deftype alone even if we aren't using them for now. We want the performance enhancements without changing the API at all.

0 votes
by

Comment made by: tmulvaney

Thanks that makes sense. Fixed in this patch.

0 votes
by

Comment made by: mfikes

CLJS-1866-updated.patch added to Patch Tender (i)

0 votes
by

Comment made by: mfikes

CLJS-1866-updated.patch passes CI and Canary (/)

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-1866 (reported by tmulvaney)
...