BAEL-4644: Small test to check Java JIT compiler performances vs C++ … (#10412)

* BAEL-4644: Small test to check Java JIT compiler performances vs C++ and JS

* BAEL-4644: Remove CSV with performance test results

* Revert "BAEL-4644: Remove CSV with performance test results"

This reverts commit a69c9667
This commit is contained in:
Daniel Strmecki 2021-01-22 08:53:02 +01:00 committed by GitHub
parent 26c646f6fc
commit d90c7fed48
4 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,19 @@
#include <iostream>
#include <chrono>
using namespace std;
int fibonacci(int n) {
if (n <= 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
int main() {
for (int i = 0; i < 100; i++) {
auto startTime = chrono::high_resolution_clock::now().time_since_epoch();
int result = fibonacci(12);
auto totalTime = chrono::high_resolution_clock::now().time_since_epoch() - startTime;
cout << totalTime << "\n";
}
}

View File

@ -0,0 +1,14 @@
function fibonacci(index) {
if (index <= 1)
return index;
return fibonacci(index-1) + fibonacci(index-2);
}
for (var i=0; i<100; i++) {
var startTime = process.hrtime.bigint();
var result = fibonacci(12);
var totalTime = process.hrtime.bigint() - startTime;
console.log(totalTime);
}

View File

@ -0,0 +1,20 @@
package com.baeldung.performancetests.jit;
public class Fibonacci {
public static void main(String[] args) {
for (int i=0; i<100; i++) {
long startTime = System.nanoTime();
int result = fibonacci(12);
long totalTime = System.nanoTime() - startTime;
System.out.println(totalTime);
}
}
private static int fibonacci(int index) {
if (index <= 1)
return index;
return fibonacci(index-1) + fibonacci(index-2);
}
}

View File

@ -0,0 +1,103 @@
Runs;Java using JIT;Java without JIT;C++ without O2;C++ with O2;JavaScript
1;21900;10572;8684;2643;35115
2;60790;10572;8306;2643;20389
3;1888;24543;7551;2265;20390
4;4153;25675;8307;2265;19256
5;1888;26053;8307;2265;19257
6;5664;25675;8307;1887;35115
7;1510;25676;29829;2266;20012
8;1510;26053;7929;2643;35493
9;1511;23787;7929;1888;40023
10;3776;26431;26053;3776;20012
11;1510;25676;7929;2265;35115
12;1510;10195;7552;3775;19256
13;17746;10572;7552;1888;40024
14;26431;10194;7552;2265;19257
15;1133;10195;8685;2265;18501
16;1133;10572;7929;2265;18879
17;1133;10572;7929;1888;53995
18;756;10195;7929;1888;35115
19;1133;10195;7930;2266;19634
20;756;10573;7552;2266;37003
21;1133;9817;7552;1888;35115
22;1133;10194;7930;2266;32472
23;1133;10195;7929;2266;18879
24;755;10195;8307;3776;19257
25;755;10195;7551;1888;34738
26;1510;10194;7551;2265;18501
27;3776;10194;7929;2266;33227
28;1888;37758;9440;1888;19634
29;1133;10573;8306;1888;32472
30;1133;26430;7929;2265;32849
31;1133;24165;8306;4153;32850
32;755;24166;7929;2643;18879
33;1133;10572;24920;4153;32850
34;755;23788;10194;2643;19257
35;756;23788;12837;4154;18501
36;755;11328;8307;2643;33227
37;1132;29829;8307;7174;1000211
38;755;36625;8307;4531;39646
39;1133;10950;7929;2643;34360
40;1133;10950;7929;4531;3021
41;1133;10573;7929;2643;2643
42;755;29829;15104;2643;2643
43;755;29829;13971;2643;3398
44;1133;10950;8685;5664;3021
45;1133;10950;9817;3020;3398
46;1133;10950;8684;3776;3020
47;1888;30962;7930;3020;3021
48;1132;10950;8307;2643;3399
49;1133;29451;7929;2265;2266
50;1133;29452;8307;23033;2265
51;755;10950;7929;2643;2266
52;755;10950;7930;2643;2643
53;755;11327;7929;4908;2265
54;755;11328;7929;2265;2643
55;1133;10572;7929;18879;16236
56;756;36248;7929;2643;2643
57;755;10572;7929;2265;2643
58;755;10950;9818;2644;2643
59;1132;10950;7929;2266;2643
60;20012;30206;7929;2266;3021
61;1133;30206;7929;2266;16613
62;1511;30206;7552;2266;2643
63;3021;30207;8307;1888;2643
64;1510;10950;7929;1888;2266
65;1510;30207;7929;2266;2644
66;1888;30207;8307;2265;2643
67;1511;29829;7929;2266;2643
68;1888;10950;7930;2265;2266
69;1510;29829;7929;21145;3020
70;1511;29829;7929;1888;16613
71;1510;30206;7929;2643;2265
72;1510;10950;7929;2266;2644
73;1888;10573;24921;18124;2266
74;1888;10573;9062;6797;2644
75;1888;10950;7929;2265;2643
76;1133;10950;7929;2266;2644
77;1133;29829;12460;2266;3020
78;755;11328;8307;2643;2266
79;755;11327;8684;2266;2643
80;1133;30206;8307;2266;2643
81;1133;29829;7929;2266;2266
82;1888;30206;7929;2266;16236
83;1510;11327;8307;2266;16613
84;1888;11327;7929;2265;2643
85;1133;10573;8307;6042;2266
86;1133;10950;7929;2643;2266
87;1133;10950;9817;2265;2265
88;755;10950;24165;2643;2643
89;755;11328;7929;3399;2643
90;755;10950;8307;4909;3020
91;755;10572;7552;23787;3020
92;1133;10572;7929;2643;3021
93;1132;10572;8307;2643;2643
94;1132;10950;7551;2266;3398
95;755;10950;23788;2265;2644
96;755;10573;7551;1888;2265
97;755;29829;12460;2266;2643
98;1132;30207;7929;2266;2265
99;1133;30206;7929;2265;2266
100;755;10572;7929;2265;2643
;;;;;
;;;;;
1 Runs Java using JIT Java without JIT C++ without O2 C++ with O2 JavaScript
2 1 21900 10572 8684 2643 35115
3 2 60790 10572 8306 2643 20389
4 3 1888 24543 7551 2265 20390
5 4 4153 25675 8307 2265 19256
6 5 1888 26053 8307 2265 19257
7 6 5664 25675 8307 1887 35115
8 7 1510 25676 29829 2266 20012
9 8 1510 26053 7929 2643 35493
10 9 1511 23787 7929 1888 40023
11 10 3776 26431 26053 3776 20012
12 11 1510 25676 7929 2265 35115
13 12 1510 10195 7552 3775 19256
14 13 17746 10572 7552 1888 40024
15 14 26431 10194 7552 2265 19257
16 15 1133 10195 8685 2265 18501
17 16 1133 10572 7929 2265 18879
18 17 1133 10572 7929 1888 53995
19 18 756 10195 7929 1888 35115
20 19 1133 10195 7930 2266 19634
21 20 756 10573 7552 2266 37003
22 21 1133 9817 7552 1888 35115
23 22 1133 10194 7930 2266 32472
24 23 1133 10195 7929 2266 18879
25 24 755 10195 8307 3776 19257
26 25 755 10195 7551 1888 34738
27 26 1510 10194 7551 2265 18501
28 27 3776 10194 7929 2266 33227
29 28 1888 37758 9440 1888 19634
30 29 1133 10573 8306 1888 32472
31 30 1133 26430 7929 2265 32849
32 31 1133 24165 8306 4153 32850
33 32 755 24166 7929 2643 18879
34 33 1133 10572 24920 4153 32850
35 34 755 23788 10194 2643 19257
36 35 756 23788 12837 4154 18501
37 36 755 11328 8307 2643 33227
38 37 1132 29829 8307 7174 1000211
39 38 755 36625 8307 4531 39646
40 39 1133 10950 7929 2643 34360
41 40 1133 10950 7929 4531 3021
42 41 1133 10573 7929 2643 2643
43 42 755 29829 15104 2643 2643
44 43 755 29829 13971 2643 3398
45 44 1133 10950 8685 5664 3021
46 45 1133 10950 9817 3020 3398
47 46 1133 10950 8684 3776 3020
48 47 1888 30962 7930 3020 3021
49 48 1132 10950 8307 2643 3399
50 49 1133 29451 7929 2265 2266
51 50 1133 29452 8307 23033 2265
52 51 755 10950 7929 2643 2266
53 52 755 10950 7930 2643 2643
54 53 755 11327 7929 4908 2265
55 54 755 11328 7929 2265 2643
56 55 1133 10572 7929 18879 16236
57 56 756 36248 7929 2643 2643
58 57 755 10572 7929 2265 2643
59 58 755 10950 9818 2644 2643
60 59 1132 10950 7929 2266 2643
61 60 20012 30206 7929 2266 3021
62 61 1133 30206 7929 2266 16613
63 62 1511 30206 7552 2266 2643
64 63 3021 30207 8307 1888 2643
65 64 1510 10950 7929 1888 2266
66 65 1510 30207 7929 2266 2644
67 66 1888 30207 8307 2265 2643
68 67 1511 29829 7929 2266 2643
69 68 1888 10950 7930 2265 2266
70 69 1510 29829 7929 21145 3020
71 70 1511 29829 7929 1888 16613
72 71 1510 30206 7929 2643 2265
73 72 1510 10950 7929 2266 2644
74 73 1888 10573 24921 18124 2266
75 74 1888 10573 9062 6797 2644
76 75 1888 10950 7929 2265 2643
77 76 1133 10950 7929 2266 2644
78 77 1133 29829 12460 2266 3020
79 78 755 11328 8307 2643 2266
80 79 755 11327 8684 2266 2643
81 80 1133 30206 8307 2266 2643
82 81 1133 29829 7929 2266 2266
83 82 1888 30206 7929 2266 16236
84 83 1510 11327 8307 2266 16613
85 84 1888 11327 7929 2265 2643
86 85 1133 10573 8307 6042 2266
87 86 1133 10950 7929 2643 2266
88 87 1133 10950 9817 2265 2265
89 88 755 10950 24165 2643 2643
90 89 755 11328 7929 3399 2643
91 90 755 10950 8307 4909 3020
92 91 755 10572 7552 23787 3020
93 92 1133 10572 7929 2643 3021
94 93 1132 10572 8307 2643 2643
95 94 1132 10950 7551 2266 3398
96 95 755 10950 23788 2265 2644
97 96 755 10573 7551 1888 2265
98 97 755 29829 12460 2266 2643
99 98 1132 30207 7929 2266 2265
100 99 1133 30206 7929 2265 2266
101 100 755 10572 7929 2265 2643
102
103