Java imperative and functional approach performance test

I love performance tests. generally I test everything myself if there is no source in the internet I must do it :) today I was reading imperative coding vs functional coding here. it stuck my mind this sentence. they’re probably equally fast and reasonable then I have to try which one is faster. here is the code package testarea; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Test { static int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10 }; static long startTime, stopTime; public static void main(String[] args) { runImperative(); runFunctional(); runImperative(); runFunctional();runFunctional();runFunctional();runFunctional(); runImperative();runImperative();runImperative();runImperative(); runFunctional(); } private static void runFunctional() { startTime = System.nanoTime(); functionalApproach(); stopTime = System.nanoTime(); System.out.println("F:"+(stopTime - startTime)); } private static void runImperative() { startTime = System.nanoTime(); imperativeApproach(); stopTime = System.nanoTime(); System.out.println("I:"+(stopTime - startTime)); } private static void imperativeApproach() { int sum = 0; for (int j = 0; j < array.length; j++) { for (int k = j + 1; k < array.length; k++) { if (k != j && array[k] == array[j]) { sum = sum + array[k]; } } } } private static void functionalApproach() { IntStream.of(array).boxed().collect(Collectors.groupingBy(i -> i)).entrySet().stream() .filter(e -> e.getValue().size() > 1).forEach(e -> { e.getValue().stream().collect(Collectors.summingInt(i -> i)); }); } } here is my output ...

September 19, 2015 · 2 min · Özkan Pakdil

I moved to lxde

I installed linux into this computer around 3 months ago. and I am loving it. as long as debian in my pc I am happy :) the other day I disabled fn key from BIOS and suspend started working also. I am not sure which one solved the problem. turning to lxde or that bios thing but still I am happy about this. because closing the lid and opening it and not finding X was frustrating. and I had a lot of restarts because of that. now it is working like it suppose to. ...

September 16, 2015 · 1 min · Özkan Pakdil

HP pavilion dv7 f keys

I bought this laptop about 2 months ago. and I directly installed xubuntu. I was not aware but F keys stop working. one day I was looking a site and wanted to see the html dom details and hit the F12. and my wireless stop working. then I realized my function key is like pressed and my F keys was not working. I research a lot but could not find anyway to fix this until roday :) you just need to disable it like this link says ...

September 15, 2015 · 1 min · Özkan Pakdil

Java microservice framework tests in SB:2.3.3.RELEASE Q:1.7.0.Final M:2.0.1 openjdk version "11.0.8" 2020-07-14 LTS

Here is total package generation times for separate modules, [INFO] micronaut-demo 0.1 ................................. SUCCESS [ 35.570 s] [INFO] quarkus-demo 1.0.0-SNAPSHOT ........................ SUCCESS [ 40.747 s] [INFO] springboot-demo 0.0.1-SNAPSHOT ..................... SUCCESS [ 9.256 s] [INFO] gatling 1.0-SNAPSHOT ............................... SUCCESS [ 0.049 s] [INFO] framewrok-benchmark 1.0-SNAPSHOT ................... SUCCESS [ 0.002 s] Size of created packages: Size in MB Name 14M micronaut/target/micronaut-demo-0.1.jar 17M quarkus/target/quarkus-demo-1.0.0-SNAPSHOT-runner.jar 18M spring-boot/target/springboot-demo-0.0.1-SNAPSHOT.jar :: Spring Boot :: (v2.3.3.RELEASE) Started DemoApplication in 2.306 seconds (JVM running for 2.833) ...

2 min · Özkan Pakdil

Java microservice framework tests in SB:2.3.3.RELEASE Q:1.7.0.Final M:2.0.1 openjdk version "14.0.2" 2020-07-14

Here is total package generation times for separate modules, [INFO] micronaut-demo 0.1 ................................. SUCCESS [ 32.058 s] [INFO] quarkus-demo 1.0.0-SNAPSHOT ........................ SUCCESS [ 37.747 s] [INFO] springboot-demo 0.0.1-SNAPSHOT ..................... SUCCESS [ 8.971 s] [INFO] gatling 1.0-SNAPSHOT ............................... SUCCESS [ 0.050 s] [INFO] framewrok-benchmark 1.0-SNAPSHOT ................... SUCCESS [ 0.001 s] Size of created packages: Size in MB Name 14M micronaut/target/micronaut-demo-0.1.jar 17M quarkus/target/quarkus-demo-1.0.0-SNAPSHOT-runner.jar 18M spring-boot/target/springboot-demo-0.0.1-SNAPSHOT.jar :: Spring Boot :: (v2.3.3.RELEASE) Started DemoApplication in 2.169 seconds (JVM running for 2.635) ...

2 min · Özkan Pakdil