My new benchmark to test speed of some compilers lazarus / 21-General ---------------------------------------------------------------------- Edson · 2025-01-04 17:54 Hi. I just want to share a new benchmark I made to test the speed of the programs generated for some compilers using https://www.onlinegdb.com. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i LANGUAGE      EXEC.TIMEJavaScrip(Node) 0.17Object Pascal   0.19Go      0.19C     0.25Java    0.25C++ 23  0.28Rust    0.39PHP 7   1.50Python3 2.95  Good for FPC that have the second position. The details of the test are in my blog: https://blogdetito.com/2025/01/03/los-lenguajes-mas-rapidos-para- este-2025/ ---------------------------------------------------------------------- 440bx · 2025-01-04 18:18 Hello Edson (or should I say Tito ?), Like you I was surprised by how well Javascript did and was looking for the test program source to see if I could see some reason why it beat compiled languages (the JIT time should have been a clear disadvantage.) can you post the Javascript code ? Thanks. ---------------------------------------------------------------------- Edson · 2025-01-04 19:06 Quote from: 440bx on January 04, 2025, 07:18:16 pmHello Edson (or should I say Tito ?), In fact. I'm Tito Edson  Quote from: 440bx on January 04, 2025, 07:18:16 pmLike you I was surprised by how well Javascript did and was looking for the test program source to see if I could see some reason why it beat compiled languages (the JIT time should have been a clear disadvantage.) A JIT compiler (like Node.js or Java use), has the advantage that know exactly the machine where the program is going to run so it can do special optimization. Moreover the Node.js JIT compiler has been well designed and optimized because corporations have invested a lot in it. Quote from: 440bx on January 04, 2025, 07:18:16 pmcan you post the Javascript code ? The code for all languages are in the post of my article: https://blogdetito.com/wp-content/uploads/2025/01/Validar-primo.zip Tell me if you have problems on download. ---------------------------------------------------------------------- 440bx · 2025-01-04 20:32 Thank you Tito Edson ---------------------------------------------------------------------- 440bx · 2025-01-04 22:23 Hello Edson, I made a few very minor changes to the Pascal source to make it more "parallel" to the javascript source and re-tested.  Only the functions "EsPrimo" and "TareaLarga" have changes, most of the changes are in "EsPrimo". Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program MedicionTiempo; uses  SysUtils, Math; { Función para verificar si un número es primo }function EsPrimo(num: LongInt): Boolean;var  i: LongInt;begin  if num <= 1 then exit(FALSE);  // mod    //EsPrimo := False           // mod  //else                         // mod  //begin                        // mod    //EsPrimo := True;           // mod  for i := 2 to Trunc(Sqrt(num)) do    begin      if num mod i = 0 then      begin        exit(FALSE);             // mod         //EsPrimo := False;      // mod        //Break;                 // mod      end;    end;     exit(TRUE);  //end;                         // modend; { Función que simula una tarea compleja de cálculo (encontrar primos en un rango grande) }procedure TareaLarga;var  i, count: LongInt;begin  count := 0;  for i := 2 to 1000000 - 1 do  { same number as in js and c }  // mod  begin    if EsPrimo(i) then    Inc(count);  { Contar los números primos encontrados }  end;  WriteLn('Cantidad de números primos encontrados: ', count);end; var  StartTime, EndTime: TDateTime;  Tiempo: Double;begin  { Capturar el tiempo de inicio }  StartTime := Now;   { Ejecutar la tarea larga }  TareaLarga;   { Capturar el tiempo de finalización }  EndTime := Now;   { Calcular el tiempo transcurrido en segundos }  Tiempo := (EndTime - StartTime) * 24 * 60 * 60;  { Convertir de días a segundos }   { Mostrar el tiempo de ejecución }  WriteLn('El tiempo de ejecución de TareaLarga() es: ', Tiempo:0:6, ' segundos');  WriteLn('El tiempo de ejecución de TareaLarga() en milisegundos es: ', Tiempo * 1000:0:3, ' ms');end. with the code above and testing multiple times and discarding the first time, I obtain an execution time of 0.157000 secs which would put FPC in first place Note that I did _not_ make any changes to optimize the algorithm, it's just more "parallel" to the code for other languages than it previously was. ETA: Highlighted single line change in TareaLarga. ---------------------------------------------------------------------- Edson · 2025-01-06 15:38 Quote from: 440bx on January 04, 2025, 11:23:26 pmHello Edson, I made a few very minor changes to the Pascal source to make it more "parallel" to the javascript source and re-tested.  Only the functions "EsPrimo" and "TareaLarga" have changes, most of the changes are in "EsPrimo". Good observation. However, it doesn't change the time when I compare in https://www.onlinegdb.com. Maybe you can do a new test for all languages and get different times. ---------------------------------------------------------------------- jwdietrich · 2025-01-06 16:46 Interestingly, Object Pascal is faster than C++, a language known for its speed. We have made a similar observation with code for simulating biological feedback loops and published it as a paper. It is available from https://doi.org/10.14201/adcaij.31762. Our results are highly debated but confirmed by your observations.