COBOL vs Java vs Python vs Perl Performance Comparison Part 1

preview_player
Показать описание
This video compares the four programming/scripting languages. How does COBOL fare against Java, Python and Perl in terms of performance? You will be surprised.

Video is copyright protected (c) 2024 Philip Yuson
Рекомендации по теме
Комментарии
Автор

It is tricky to do comparisons when simple loops are involved, as compilers or runtimes use optimisations to exclude unnecessary code. As the Java results are so suspicious, it is quite likely that JVM (JIT compiler) optimises the code and does not really execute the loop the expected number of times. For comparison, I added a trivial conditional increment in the inner loop to prevent optimisation, and the total execution time went from 0.09 sec to 5.9 sec:

public class Test {
public static void main(String[] args) {
int series = 0;
int accum = 0;
int result = 0;
while (series <= 10_000) {
series++;
accum = 0;
while (accum <= 1_000_000) {
accum++;
if (accum % 100 == 0) {
result++;
}
}
}
System.out.println("series: " + series);
System.out.println("accum: " + accum);
System.out.println("result: " + result);
}
}

IgorKuzmitshov
welcome to shbcf.ru