I tested the programs (and will continue to test), looked at certain places of the compiler. Optimization of the FPC compiler itself stalled about 10 years ago. Apparently, no one was engaged in it and everyone relies on computer resources.
I really wonder how you come to that conclusion, cause if you look at the history of e.g. the x86 specific optimizations you can see that it's actively worked on, same for other platforms. Only because what you consider a good optimization is not done does not mean that no optimizations are done, because it all depends on what the devs priortize.
Я ни кого не хотел задеть своими словами! Я просто слишком прямолинеен, это моя достаточно плохая черта.
Переходя по ссылке мы увидим, что какими-то определёнными оптимизациями занимается в основном один человек (остальных не видно, но это не значит что они ни чего не делают). Но один человек - это очень мало. Учитывая сколько платформ поддерживается.
google translate:
I didn't want to hurt anyone with my words! I'm just too straightforward, that's my bad enough trait.
By clicking on the link, we will see that basically one person is engaged in some specific optimizations (the rest are not visible, but this does not mean that they are not doing anything). But one person is very little. Considering how many platforms are supported.
In some cases, you can abandon Pascal's "String" and work with the text yourself. The compiler often (if you want to perform some actions with the text yourself) adds code that incurs additional costs (this is correct for most! Rarely, but some people want to control the process of working with the text themselves).
The StrToInt function is outdated (probably StrToFloat too, I didn't check it). By means of Pascal (not even assembler), it can be accelerated at least twice, if not more. You can't speed up the IntToStr function with pascal, text overhead is added, and in this case the compiler copes with the text quite well.
The point of Pascal is ease of use and not to squench the last bit of performance out of the code. If you need that you either drop to a lower level and use e.g. PChar instead of AnsiString or simply use a different language that generates code as you like it (e.g. C++). Also this ease of use also includes maintainability of both the compiler and the RTL. Sure you can write StrToInt in assembly for every platform, but then this means a higher maintainance burden.
Основной смыл моих слов был в том, что я написал слово:
Паскаль.

И я прекрасно выразился, что сам паскаль меня устраивает! Оптимизация, как я считаю, не достаточная. И больше банальная оптимизация. Где явно видно, что ни какого изменения в коде не будет в процессе работы программы, но компилятор не преобразует такие моменты. Или преобразует, но не всегда или частично. Или вообще только для одной платформы - Windows.
Было бы интересно узнать, а в чём разница между Windows 64 bit и Linux 64 bit, которые идут на одной платформе x86? Почему для Windows оптимизация идёт, а для Linux нет? Примеры с Single/Double, которые используются при вызовах процедур и вычислении определённых данных - думаю достаточно яркие. Windows - оптимизация работает. Linux - оптимизации нет. (
Извиняюсь, что вновь поднимаю этут тему, но как пример неплохо подойдёт.)
Теперь то, что явно не оптимизировано.
Google translate:
The main meaning of my words was that I wrote the word:
Pascal.

And I put it perfectly that Pascal himself suits me!Optimization, in my opinion, is not sufficient. And more banal optimization. Where it is clearly seen that no change in the code will be in the process of the program, but the compiler does not transform such moments. Or transforms, but not always or partially. Or generally only for one platform - Windows.
It would be interesting to know what is the difference between Windows 64 bit and Linux 64 bit, which are on the same x86 platform? Why is there optimization for Windows, but not for Linux? Examples with Single / Double, which are used when calling procedures and calculating certain data - I think they are quite bright. Windows - optimization works. Linux - no optimization. (
Sorry to bring this up again, but as an example it will work well.)
Now something that is clearly not optimized. StrToInt example:
const
isByte = 0; // len = 3 0..255
isShortInt = 4; // len = 4 -128..127
isWord = 1; // len = 5 0..65535
isSmallInt = 5; // len = 6 -32768..32767
isLongWord = 2; // len = 10 0..4294967295
isInteger = 6; // len = 11 -2147483648..2147483647
{$If defined(CPUX86_64) or defined(aarch64)}
isQWord = 3; // len = 20 0..18446744073709551615
isQInt = 7; // len = 20 -9223372036854775808..9223372036854775807
{$IfEnd}
type
geUseParametr = record
maxLen: LongWord;
{$If defined(CPUX86_64) or defined(aarch64)}
maxNumDiv10: QWord;
maxNumeric: QWord;
{$Else}
maxNumDiv10: LongWord;
maxNumeric: LongWord;
{$IfEnd}
var
resInt64: Int64; // integer ???
procedure SetNumberParametr; //call at the very beginning. This is to speed up translation work.
function geStrToInt(Str: String; Size: LongWord = isInteger): Boolean;
implementation
var
allUseParametr: array[0..7] of geUseParametr;
procedure SetNumberParametr;
begin
allUseParametr[isByte].maxLen := 3;
allUseParametr[isByte].maxNumeric := 255;
allUseParametr[isByte].maxNumDiv10 := 25;
allUseParametr[isShortInt].maxLen := 4;
allUseParametr[isShortInt].maxNumeric := 127;
allUseParametr[isShortInt].maxNumDiv10 := 12;
allUseParametr[isWord].maxLen := 5;
allUseParametr[isWord].maxNumeric := 65535;
allUseParametr[isWord].maxNumDiv10 := 6553;
allUseParametr[isSmallInt].maxLen := 6;
allUseParametr[isSmallInt].maxNumeric := 32767;
allUseParametr[isSmallInt].maxNumDiv10 := 3276;
allUseParametr[isLongWord].maxLen := 10;
allUseParametr[isLongWord].maxNumeric := 4294967295;
allUseParametr[isLongWord].maxNumDiv10 := 429496729;
allUseParametr[isInteger].maxLen := 11;
allUseParametr[isInteger].maxNumeric := 2147483647;
allUseParametr[isInteger].maxNumDiv10 := 214748364;
{$If defined(CPUX86_64) or defined(aarch64)}
allUseParametr[isQWord].maxLen := 20;
allUseParametr[isQWord].maxNumeric := 18446744073709551615;
allUseParametr[isQWord].maxNumDiv10 := 1844674407370955161;
allUseParametr[isQInt].maxLen := 20;
allUseParametr[isQInt].maxNumeric := 9223372036854775807;
allUseParametr[isQInt].maxNumDiv10 := 922337203685477580;
{$IfEnd}
end;
// проверки на печатаемые символы не производится
function geStrToInt(Str: String; Size: LongWord = isInteger): Boolean;
var
lenStr, i: LongWord;
m, n, z: QWord;
begin
Result := False;
if (Size < 4) or (Size > 7) then
Exit;
// обнуляем, и флаг изначально указан, что не действителен
resInt64 := 0;
IntMinus := False;
lenStr := Length(Str);
if lenStr = 0 then
exit;
i := 1;
m := Byte(Str[1]);
if m = 45 then
begin
if lenStr = 1 then
exit;
IntMinus := True;
inc(i);
m := Byte(Str[2]);
// dec(lenStr);
end;
inc(i);
m := m - 48;
// проверяем на установленную длину. Но сначала проверим на знак.
if lenStr > allUseParametr[Size].maxLen then
Exit;
while i < lenStr do
begin
m := m * 10 + (Byte(Str[i]) - 48);
inc(i);
end;
// Если уже превысили, то выходим
if m > allUseParametr[Size].maxNumDiv10 then
exit;
m := m * 10;
z := Byte(Str[i]) - 48;
// обработку размерностей и Word и Int надо разделить
if IntMinus then
n := allUseParametr[Size].maxNumeric + 1 - m
else
n := allUseParametr[Size].maxNumeric - m;
if z > n then
exit;
if IntMinus then
resInt64 := - m - z
else
resInt64 := m + z;
Result := true;
end;
ускорение достаточное для платформы x86 и по моему слишком большое для ARM (у меня изменения скорости показывало на Android в 3-12 раз!).
Следует учесть, что ни каких исключений в коде не произойдёт. Я от них попросту избавился. А StrToInt-FPC может вызвать исключения. В данном коде если число не будет переведено, то мы об этом узнаем по результату функции Boolean. И можем считать данное число из resInt64, если результат был вычислен. Использовать можно для любых платформ.
Ещё раз повторюсь, я не говорю, что команда по разработке FPC не работает! Я говорю, что мелочами занимаются достаточно мало. И я это понимаю, потому что мелочи - это неблагодарная работа, на которую надо много времени, а результат не всегда хороший.
Google translate:
acceleration is sufficient for the x86 platform and, in my opinion, is too large for ARM (my speed changes showed 3-12 times on Android!).
Please note that no exceptions will occur in the code. I just got rid of them. StrToInt-FPC can throw exceptions. In this code, if the number is not translated, then we will find out about it by the result of the Boolean function. And we can read the given number from resInt64, if the result was calculated. Can be used for any platform.
Again, I'm not saying that the FPC development team isn't working! I say that little things are done very little. And I understand this, because little things are a thankless job that takes a lot of time, and the result is not always good.
P.S. Это только у меня StrToInt не хочет работать на Android? Мне приходится использовать Val напрямую.
P.S. Is it just me StrToInt doesn't want to work on Android? I have to use Val directly.