Follow the procedure to run JMH tests:
$ mvn clean install
$ java -jar target/benchmarks.jar
JAYield provides an extensible lazy sequence
API, which reduces verbosity, keeps fluent query invocation and is faster than
Java
Stream
API for sequential traversing with user-defined custom operations (e.g. oddLines
or collapse).
In this work, we compare the performance of JAYield with the Java Stream API and with some of the most popular functional style Java libraries, such as Guava, StreamEx, JOOL, Cyclops, Vavr, and Protonpack.
We evaluated these libraries in a realistic use case based on data from the World Weather Online API for a small data set with past weather of Lisbon in February, March and April, corresponding to 93 days of weather information and performing 3 different queries:
- QueryMaxTemperature - maximum temperature;
- QueryNrOfDistinctTemperatures - count the number of distinct temperatures;
- QueryNrOfTemperaturesTransitions - count temperature transitions.
Each query results in a pipeline of:
filter-skip-oddLines-mapToInt-max;filter-skip-oddLines-map-distinct-count;filter-skip-oddLines-map-collapse-count.
Note that oddLines and collapse are user-defined custom operations according
to each library extension API.
The JAYield approach is is 2 fold faster than Java Stream on QueryMaxTemperature
and 3 fold faster on QueryNrOfTemperaturesTransitions, which combines two
custom operations (oddLines() and collapse()).
All other libraries also show worse performance than JAYield and furthermore, none of them provides an extensible fluent API as JAYield.