This irks me. Why can't I write my equations in natural form?

This irks me. Why can't I write my equations in natural form?

program WhyDoEmbarcaderoNotCareAboutPerformance;

{$APPTYPE CONSOLE}

uses
System.Diagnostics;

const
RepCount = 25000;

var
Data: array [0..8191] of Double;

procedure Main;
var
i, j, rep: Integer;
Stopwatch: TStopwatch;
begin
Writeln('/2.0');
for j := 1 to 5 do begin
for i := low(Data) to high(Data) do begin
Data[i] := 666*i;
end;

Stopwatch := TStopwatch.StartNew;
for rep := 0 to RepCount-1 do begin
for i := low(Data) to high(Data) do begin
Data[i] := Data[i]/2.0;
end;
end;
Writeln(Stopwatch.ElapsedTicks);
end;

Writeln('*0.5');
for j := 1 to 5 do begin
for i := low(Data) to high(Data) do begin
Data[i] := 666*i;
end;

Stopwatch := TStopwatch.StartNew;
for rep := 0 to RepCount-1 do begin
for i := low(Data) to high(Data) do begin
Data[i] := 0.5*Data[i];
end;
end;
Writeln(Stopwatch.ElapsedTicks);
end;
end;

begin
Main;
Readln;
end.

Comments

  1. Marco Cantù This is so dispiriting. It all seems like a waste of time though. You've sat on all my floating point bugs for years and done absolutely nothing. You know that Set8087CW and SetMXCSR are not threadsafe? You know that this makes floating point code effectively incompatible with multi-threading?

    ReplyDelete
  2. I know I know. They are very high on my personal list.

    ReplyDelete
  3. Marco Cantù​ I hope you remember to seek my comment and input if and when you get to tackle these matters

    ReplyDelete

Post a Comment