Commit Graph

91 Commits

Author SHA1 Message Date
98bdb35c40 update gradle versions plugin to 0.24.0 2019-09-07 17:54:50 +02:00
0751802dd0 update gradle to 5.6.2 2019-09-07 17:53:38 +02:00
6421b82ce1 remove benchmark harness
we are using JMH instead
2019-09-07 17:52:14 +02:00
9f60c59aca add JMH tests for union of long list and uniq of lon/int list 2019-09-07 17:49:53 +02:00
452ef2020d fix LongLongHashMap.forEachOrdered for negative values 2019-09-07 16:51:30 +02:00
4d92197423 fix stackoverflow in Int/LongList.intersectionUnsorted 2019-09-07 16:50:40 +02:00
86f12e0af6 Add hash map for long to long mappings. 2019-09-07 14:36:51 +02:00
097b7ab110 add more JMH tests 2019-09-01 15:47:10 +02:00
0311ecd83c recover deleted JMH tests
update gradle and other third-party libs
2019-08-22 19:57:27 +02:00
506fb7b698 add new method 'uniq()' 2019-08-22 19:21:24 +02:00
ed703db277 speed improvement for intersectionSorted()
Using the unsafe versions of add/get to improve performance.

Here are some numbers for 2^15 intersections of two random
sorted lists with 16k elements. The numbers were gathered with
perf stat -d -d -d --delay 2000 java -ea -cp bin/test:bin/main
org.lucares.collections.Test 16000 15 (the test class is not committed)

Duration: 9059ms -> 7293ms (80.5%)
Cycles: 26.084.812.051 -> 21.616.608.207 (82.9%)
Instructions: 68.045.848.666 -> 52.306.000.150 (76.9%)
Instructions per Cycle: 2,61 -> 2.42
Branches: 15.007.093.940 -> 9.839.481.658 (65.6%)
Branch Misses: 2.285.461 -> 1.551.906
Cycles per element: 24.87 -> 20.61 (82.9%)
2019-04-28 12:48:17 +02:00
cedccefe92 20% speedup of unionSorted()
Added getUnsafe and addUnsafe, two methods that skip checks.
The checks are not needed in unionSorted, because we made
sure the code works correctly. getUnsafe still has the checks,
but as assertions.

The speedup is roughly 20%. Here are some results for calling
union 2^16 times for two random sorted lists with 16k
elements:
Duration: 20170 -> 16857 (83.57%)
Instructions: 138.277.743.679 -> 108.474.027.213 (78.4%)
Instructions per cycle: 2,33 -> 2,18
Branches: 30.248.330.644 -> 19.908.207.057 (65.8%)
Branch Misses: 3.012.427 -> 3.477.433
Cycles per list element: 65.93 -> 51.72 (78.4%)

Created with (the test program is not committed) on a Core2Duo 8600:
perf stat -d -d -d --delay 2000 java -cp bin/test:bin/main
org.lucares.collections.Test 16000 16
2019-04-28 11:05:13 +02:00
1420c21732 update 3rd party libs and gradle 2019-04-27 18:04:59 +02:00
528e0b3ba3 update gradle to 5.2.1 2019-02-17 09:13:40 +01:00
b31f756500 addAll for a collection of LongLists
The benefit is, that we only need one memory allocation.
2019-02-17 09:11:09 +01:00
e594e09946 update junit 2019-01-04 17:02:23 +01:00
635458778b update gradle to 5.1 2019-01-04 16:59:04 +01:00
5072f43474 update version 2018-11-20 19:57:31 +01:00
ee04f21f29 removeAll is now O(n+m) if both lists are sorted 2018-11-20 19:53:33 +01:00
430b4c50ca update 4rd-party libs 2018-11-20 19:25:34 +01:00
6cc4a704fe add .reviewboardrc so that we might be able to use the review board 2018-11-09 07:03:11 +01:00
fef9af51cd add different versions of IntList.insert and LongList.insert
The new methods are more flexible, so that you can insert
parts of an array.
2018-09-23 15:28:37 +02:00
b99021d0f7 extract duplicate code that checks if the list is sorted 2018-09-13 20:02:54 +02:00
29e298dd35 add information on how to get artifacts 2018-09-13 17:53:25 +00:00
7201dde072 update README.md with a list of supported methods and an example 2018-09-13 17:42:53 +00:00
9bf4abe3ec add gradle-versions plugin and update junit to 5.3.1 2018-09-13 19:05:35 +02:00
81fb565b1d update gradle to 4.10.1 2018-09-13 19:01:02 +02:00
1d0d3e6d2b add *List.range() and *List.rangeClosed() 2018-09-08 08:48:47 +02:00
336905fafe clear() not longer frees memory it just empties the list
Use case: The list is used as a buffer, that is re-used and in
each iteration the list is cleared.

Now that clear() does not replace the data array there is no
garbage collection and we do not have to allocated one or
several new arrays in the next iteration.
You can still free the associated memory by calling clear() + trim().
2018-08-17 19:38:30 +02:00
1994400f97 make jnuit5 tests actually executable in gradle 2018-08-17 19:34:42 +02:00
a8658480ce update to gradle 4.9 2018-08-17 18:45:15 +02:00
19886eff89 update to Junit 5 2018-08-17 18:44:38 +02:00
a5b58cb1b5 update gradle to 4.7 2018-05-19 19:50:19 +02:00
fa0c7136a4 add LongList
It is an exact copy of IntList.
2018-01-24 19:15:19 +01:00
bd6c595856 extract inline definitions of generators, add loop for different sizes 2018-01-22 18:51:40 +01:00
bfbddf3fb1 cleanup
- Remove TODO in unionUnsorted, because I don't think there is a much
  better solution.
- Remove TODO for lastIndexOf, because it has been implemented.
- Use local variables for size in unionSorted.
2018-01-22 18:50:53 +01:00
7edd2adad8 cleanup
remove obsolete jmh test
2018-01-22 18:23:18 +01:00
7de2ac1fd3 add test for hashcode/equals with sorted and unsorted lists 2018-01-22 18:22:14 +01:00
67c16460d8 remove jmh 2018-01-22 18:21:40 +01:00
c5e49b388b update gradle to 4.4.1 2018-01-22 18:14:10 +01:00
8ee6118854 make unionUnsorted 5-10% faster for lists with 100k elements 2018-01-21 19:55:25 +01:00
5515523100 add simple benchmarking helper 2018-01-21 19:53:15 +01:00
ec32e3f566 unsorted lists can become sorted after removal
The old code only set the list to sorted when the lists size was <= 1
after the removal.
2017-12-20 18:59:24 +01:00
c73d43c214 replace removeAll/retainAll implementation with one a removeIf based
The algorithms for removeAll, retainAll and removeIf were almost
identical. The main difference was, that removeIf calls a lambda,
whereas removeAll and retainAll executed the check directly. Both
methods call indexOf on an IntList, which easily outweighs the extra
cost of the lambda.
It makes sense to consolidate and remove the duplicated code.

I ran a few benchmarks with different list sizes before the replacement.
The results are not as clear as I would have liked. In some cases,
especially for short lists, the special implementations of
removeAll/retainAll were up to 10% faster. In other situations I saw
50% difference the one day, but could not reproduce those results a 
day later. This leads me to believe, that my test setup is not
trustworthy.
That means I stay with what I now. The code is identical with one tiny
difference. And that difference shouldn't matter, because indexOf is 
much more expensive.
2017-12-20 18:45:42 +01:00
1681183474 add JMH
Add benchmark for a comparison of the custom made removeAll
method vs an implementation that uses removeIf
2017-12-20 17:51:15 +01:00
45dd73d8f3 update isSorted after shuffling
A list can be sorted after shuffling. The trivial cases are
the empty list and a list with only one element or lists 
with only identical elements. Lists with only a few elements 
have a non-negligible chance to be sorted after shuffling.
2017-12-18 20:10:27 +01:00
297ab6fd40 only trim if size != capacity 2017-12-18 19:50:45 +01:00
5006581cf0 allocate only as much as is needed
ensureCapacity would allocate up to 50% too much memory
2017-12-16 14:49:20 +01:00
f3cbdda121 early exit it toString was only used if data array was empty 2017-12-16 14:34:36 +01:00
76145b080e update gradle to 4.4 2017-12-13 20:44:49 +01:00