Skip to content

Commit

Permalink
improve print and time
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragicafit committed Jan 27, 2022
1 parent 80e4a0a commit 5c9f137
Show file tree
Hide file tree
Showing 13 changed files with 888 additions and 38 deletions.
6 changes: 3 additions & 3 deletions Blender.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public void multiply(double factor) {

public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
initialize(new Color(j / 20, 0, 1));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Blender2.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public void multiply(double factor) {

public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
initialize(new Color(j / 20, 0, 1));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Blender3.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public void multiply(double factor) {
private static final Color[][][] colors = new Color[100][100][100];

public static void main(String[] args) {
b=args.length==1;
b = args.length == 1;
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
initialize(new Color(j / 20, 0, 1));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Blender4.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public void add(Color other) {

public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
initialize(new Color(j / 20));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Blender5.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public void add(Color other) {

public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
initialize(new Color(j / 20));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Blender6.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public void add(Color other) {

public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
initialize(new Color(j / 20));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Blender7.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public void add(Color other) {

public static void main(String[] args) {
for (int j = 0; j < 10; j++) {
long t = System.nanoTime();
long t = System.currentTimeMillis();
for (int i = 0; i < 1; i++) {
initialize(new Color(j / 20));
}
long d = System.nanoTime() - t;
System.out.println(d / 1_000_000 + " ms");
System.out.println(System.currentTimeMillis() - t);
System.out.println(colors.length);
}
}

Expand Down
28 changes: 15 additions & 13 deletions Fibo2.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
public class Fibo2 {
public static void main(String[] args) {
fibo(45, 40);
System.out.println(fibo(45, 40));
}
static long fibo(long n, long print){

static long fibo(long n, long print) {
if (n == 0) {
return 0;
}
if (n == 1) {
return 1;
}
return 0;
}
if (n == 1) {
return 1;
}

long start = 0;
if (n == print) {
start = System.currentTimeMillis();
}
long result = fibo(n - 1, print) + fibo(n - 2, print);
if (n == print) {
long start = System.currentTimeMillis();
long result = fibo(n - 1, print) + fibo(n - 2, print);
long end = System.currentTimeMillis() - start;
System.out.println("fibo("+print+") in : "+end+" ms");
System.out.println(System.currentTimeMillis() - start);
}

return fibo(n - 1, print) + fibo(n - 2, print);
return result;
}
}
2 changes: 1 addition & 1 deletion Fibo3.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

public class Fibo3 {
public static void main(String args[]) {
fibo(40);
System.out.println(fibo(42));
}

static long fibo(long n) {
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ JAVAC = $(GRAALVM_HOME)/bin/javac
JAVA = $(GRAALVM_HOME)/bin/java
NATIVE_IMAGE = $(GRAALVM_HOME)/bin/native-image

VM_OPT_FOR_OPENJDK = -XX:-UseJVMCICompiler -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:+PrintAssembly
VM_OPT_FOR_GRAALVM = -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation -XX:+PrintAssembly
VM_OPT_FOR_OPENJDK = -XX:-UseJVMCICompiler -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
VM_OPT_FOR_GRAALVM = -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation

BUILD_FOLDER = bin

Expand Down
Binary file added compare.ods
Binary file not shown.
Loading

0 comments on commit 5c9f137

Please sign in to comment.