Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build of Java version with and without primitive types #2

Open
jlahoda opened this issue Feb 10, 2016 · 2 comments
Open

Build of Java version with and without primitive types #2

jlahoda opened this issue Feb 10, 2016 · 2 comments

Comments

@jlahoda
Copy link

jlahoda commented Feb 10, 2016

boxed-sieve.zip
primitive-sieve.zip

@jtulach
Copy link
Owner

jtulach commented Feb 10, 2016

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...

@jlahoda
Copy link
Author

jlahoda commented Feb 15, 2016

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) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants