program Benchmark;
{$APPTYPE CONSOLE}
uses
SysUtils, DateUtils;
var
StartTime, EndTime: TDateTime;
Total: Int64;
NumOfIterations3, NumOfIterations5, NumOfIterations15: Int64;
Sum3, Sum5, Sum15: Int64;
Duration: Double;
Key: Char;
begin
// Start measuring time
StartTime := Now;
NumOfIterations3 := 1000000000 div 3;
NumOfIterations5 := 1000000000 div 5;
NumOfIterations15 := 1000000000 div 15;
Sum3 := NumOfIterations3 * (NumOfIterations3 + 1) div 2 * 3;
Sum5 := NumOfIterations5 * (NumOfIterations5 + 1) div 2 * 5;
Sum15 := NumOfIterations15 * (NumOfIterations15 + 1) div 2 * 15;
Total := Sum3 + Sum5 - Sum15;
// Stop measuring time
EndTime := Now;
Duration := SecondsBetween(EndTime, StartTime);
Writeln('Total: ', Total);
Writeln('Time taken: ', Duration:0:6, ' seconds');
Write('Press any key to exit');
Readln(Key);
end.
What about this code optimization?