изменена реализация Abs для целых на тривиальную. Ускорение - в 2.5 раза

This commit is contained in:
Mikhalkovich Stanislav 2022-05-03 16:09:34 +03:00
parent ea669a4c4f
commit 1d09aa7a15
7 changed files with 24 additions and 13 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3"; public const string Major = "3";
public const string Minor = "8"; public const string Minor = "8";
public const string Build = "3"; public const string Build = "3";
public const string Revision = "3113"; public const string Revision = "3114";
public const string MainVersion = Major + "." + Minor; public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=8
%REVISION%=3113
%COREVERSION%=3 %COREVERSION%=3
%REVISION%=3114
%MINOR%=8
%MAJOR%=3 %MAJOR%=3

View file

@ -0,0 +1,11 @@
// Abs для целых работает в 2.5 раза быстрее Math.Abs
begin
var s := 0;
var n := MaxInt;
loop n do
s := Abs(-2);
Print(MillisecondsDelta);
loop n do
s := System.Math.Abs(-2);
Print(MillisecondsDelta);
end.

View file

@ -1 +1 @@
3.8.3.3113 3.8.3.3114

View file

@ -1 +1 @@
!define VERSION '3.8.3.3113' !define VERSION '3.8.3.3114'

View file

@ -8275,13 +8275,13 @@ function Sign(x: uint64): integer := 1;
function Sign(x: real): integer := Math.Sign(x); function Sign(x: real): integer := Math.Sign(x);
function Abs(x: shortint): shortint := Math.Abs(x); function Abs(x: shortint): shortint := if x >= 0 then x else -x;
function Abs(x: smallint): smallint := Math.Abs(x); function Abs(x: smallint): smallint := if x >= 0 then x else -x;
function Abs(x: integer): integer := Math.Abs(x); function Abs(x: integer): integer := if x >= 0 then x else -x;
function Abs(x: int64): int64 := Math.Abs(x); function Abs(x: int64): int64 := if x >= 0 then x else -x;
function Abs(x: BigInteger): BigInteger := BigInteger.Abs(x); function Abs(x: BigInteger): BigInteger := BigInteger.Abs(x);

View file

@ -8275,13 +8275,13 @@ function Sign(x: uint64): integer := 1;
function Sign(x: real): integer := Math.Sign(x); function Sign(x: real): integer := Math.Sign(x);
function Abs(x: shortint): shortint := Math.Abs(x); function Abs(x: shortint): shortint := if x >= 0 then x else -x;
function Abs(x: smallint): smallint := Math.Abs(x); function Abs(x: smallint): smallint := if x >= 0 then x else -x;
function Abs(x: integer): integer := Math.Abs(x); function Abs(x: integer): integer := if x >= 0 then x else -x;
function Abs(x: int64): int64 := Math.Abs(x); function Abs(x: int64): int64 := if x >= 0 then x else -x;
function Abs(x: BigInteger): BigInteger := BigInteger.Abs(x); function Abs(x: BigInteger): BigInteger := BigInteger.Abs(x);