vavr-io / vavr-benchmark Goto Github PK
View Code? Open in Web Editor NEWBenchmarks for VAVR
License: Apache License 2.0
Benchmarks for VAVR
License: Apache License 2.0
Hold your horses! Future still needs to be added to the branch ;)
Take a look at the Scala benchmark: scala/scala#7663
Now that jcstress is finally available on Maven, we should create some stress tests.
Some contenders with mutable inner state that should definitely be validated:
find
, await
, cancel
, complete
, onComplete
, isEmpty
, run
, tryComplete
@jest reported performance degradation of Array.permutations()
in vavr:0.9.0
. It seems the problem commit is 9e37950e2fa3113cba6fbcd03feebd1fc86ca1e1
Here is (slightly modified for testing) old code:
public static <T> Array<Array<T>> permOld(Array<T> array) {
if (array.isEmpty()) {
return Array.empty();
} else {
final Array<T> tail = array.tail();
if (tail.isEmpty()) {
return Array.of(array);
} else {
final Array<Array<T>> zero = Array.empty();
return array.distinct().foldLeft(zero, (xs, x) -> {
final Function<Array<T>, Array<T>> prepend = l -> l.prepend(x);
return xs.appendAll(array.remove(x).permutations().map(prepend));
});
}
}
}
And here is new code:
public static <T> Array<Array<T>> permNew(Array<T> array) {
if (array.isEmpty()) {
return Array.empty();
} else {
Array<Array<T>> results = Array.empty();
for (T t : array.distinct()) {
for (Array<T> ts : array.remove(t).permutations()) {
results = results.append(Array.of(t).appendAll(ts));
}
}
return results;
}
}
useIsEqualToInsteadOfIsSameAs()
from unit tests and test for isSameAs()
Example: take(0)
// AbstractTraversableTest
@Test
public void shouldTakeNoneOnNil() {
if (useIsEqualToInsteadOfIsSameAs()) {
assertThat(empty().take(1)).isEqualTo(empty());
} else {
assertThat(empty().take(1)).isSameAs(empty());
}
}
// PriorityQueue (current)
@Override
public PriorityQueue<T> take(int n) {
return ofAll(comparator, iterator().take(n));
}
// PriorityQueue (time and mem saver)
@Override
public PriorityQueue<T> take(int n) {
if (n <= 0) {
return this;
} else if (n >= size()) {
return empty(comparator());
} else {
return ofAll(comparator, iterator().take(n));
}
}
This was only an example. We have many similar occurrences.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.