How does java optimize compilation?

the following 2 pieces of C-sharp and java code. C-sharp is compiled in debug mode by default, and the speed is the same as that compiled by java with javac. It takes 10s to perform 2 billion floating-point operations, but if C-sharp is compiled in release mode, only 3sQuery java is used. Is there a similar optimization?
(I have seen the options of javac, it seems that none of them can be optimized and compiled, and the corresponding information can not be found on the Internet)

C-sharp Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program {

static void Main(string[] args){
    double i = 0.0; double j = 0.0;
    System.DateTime currentTime = new System.DateTime();
    currentTime = System.DateTime.Now;
    System.Console.Write(currentTime);
    System.Console.Write("\n");
    for (i=0.0; i < 2000000000.0; iPP) { j = i + j; }
    currentTime = System.DateTime.Now;
    System.Console.Write(currentTime);
    System.Console.Read();
}

}

java Code:
import java.util.Date;
import java.text.SimpleDateFormat;
public class a {

public static void main(String[] args) {
    double i=0.0,j=0.0;
    Date date = new Date();
    SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
    System.out.println(dateFormat.format(date));
    for(i=0.0;i<2000000000.0;iPP){
        j=i+j;
    }
    Date date1 = new Date();
    SimpleDateFormat dateFormat1= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
    System.out.println(dateFormat1.format(date1));
}

}-sharp-sharp-sharp problem description

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Apr.01,2021

what you are talking about should be the optimization of the just-in-time compiler, not the optimization of javac. It just converts the code into bytecode, and the bytecode to machine code will also use the real-time compiler (JIT),. You can take a look at the relevant knowledge. Generally, if the execution time is too long, it will automatically trigger the optimization strategy of the real-time compiler. understand JIT

Menu