sieve
sieve copied to clipboard
Build of Java version with and without primitive types
The above ZIP files (in fact JAR) files contain compiled classes from Natural, Filter, Primes sources - one version is using Java primitive types (e.g. int and long) and the other is using boxed versions (java.lang.Integer and java.lang.Long). To execute the programs use:
$ wget https://github.com/jtulach/sieve/files/124753/boxed-sieve.zip
$ java -jar boxed-sieve.zip
and
$ wget https://github.com/jtulach/sieve/files/124754/primitive-sieve.zip
$ java -jar primitive-sieve.zip
Right now the primitive version is >2x faster than the boxed one. However (with a good JVM) there is no reason for that...
Attaching two more files: boxed-sieve2.zip: similar to boxed-sieve.zip, but some unnecessary unboxing&reboxing removed/fixed.
almost-primitive-siever.zip: a version where Filter is not keeping a primitive value, but rather a boxed value, using this patch:
--- Filter.java 2016-02-03 14:28:44.000000000 +0100
+++ Filter.java 2016-02-15 14:52:29.867059042 +0100
@@ -1,7 +1,7 @@
package org.apidesign.demo.sieve.js;
final class Filter {
- private final int number;
+ private final Integer number;
private final Filter next;
public Filter(int number, Filter next) {