RangedIterator performance tweaks

Description

The attached patch simplifies and speeds up the RangedIterator.

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

1 2 3 4 5 6 7 (defn consume-iterator [v] (let [iter (-iterator v)] (loop [] (when (.hasNext iter) (.next iter) (recur)))))

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

1 (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 [msec] (master)

V8 Speed [msec] (patch)

JSC Speed [msec] (master)

JSC Speed [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.

Environment

None

Status

Assignee

Thomas Mulvaney

Reporter

Thomas Mulvaney

Labels

Approval

None

Patch

Code

Priority

Minor