Jump to content

Tommi Prami

Members
  • Content Count

    602
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by Tommi Prami


  1. Hello,

     

    Tried to find the documentation of [ref] attribute, famously used in FreeAndNil -implementation lately, but could not find it from Embacdero help.
    (FreeAndNil is defined as: procedure FreeAndNil(const [ref] Obj: TObject);)

    So could someone point me to the documentation of the attribute ands/or explain what it actually does?

     

    -Tee-


  2. Yellow, again...

     

    Did Quick tests with PPL, seems that tested code it self did not work wery well when runniing in parallel.

    Do'h

    Heve to to think of this later... Code should be about thread safe, but did not cope, or at least I did not saw anything that was obviously not thhread safee and protected few spots with Critical section.

    -Tee-

    • Like 1

  3. Yellow,

    Has anyone done parallel tests, of some kind. 

    Some tests I have to run takles quite a long time, and might be nice to run those in parallel.,

    In this case tests are just procedure with all code, that does something for different inputs (from predefined array etc). So in theory it would be simple, with TTask from PPL. I was just thinking what I have to take into consideration if test fails etc. I would need to use PPL, for these, sadly OTL is not possibility. 

    As far as I know, there is nothing built in in the DUnitX.

    -Tee-

     

    • Like 1

  4. On 2/7/2025 at 12:43 PM, Stefan Glienke said:

    Although these particular differences are most likely because of the following two improvements I provided:

    Any optimization that makes Object/Recor "init/deinit" faster is surely good optimization. These will make almost mall apps faster.

    Other good candidates would be TList, TStrings, TDataSet  (and descendants), just on top of my head. All in those would help in many places.

    Surely there are tons of places in RTL thatb would need some love...


  5. On 2/7/2025 at 12:43 PM, Stefan Glienke said:

    P.S. Just FYI if I run the benchmark without the empty ctor and dtor in Delphi 12 release config I get these numbers:

    
    BaseClass: 106,01 ms
    unneeded inheritance: 119,40 ms

    The same code compiled in Delphi 10.1 gives these numbers - so much about "there is no progress on optimization":

    
    BaseClass: 156,23 ms
    unneeded inheritance: 175,53 ms

     

    That is quite nice. Thanks for info.

    • Like 1

  6. On 2/7/2025 at 12:43 PM, Stefan Glienke said:

    I am all for better optimization performed by the compiler but this particular case is not among them - if you write empty methods then use some static code analysis to let them be detected and remove them.

    For sure. I just thought (or hoped) that this kind of unneeded stuff would be optimized out quite from the start.

    Curiocity came from, that I stumbled upon that kind of code, not that deep for sure as my example, just wanted to measure, and report the results here.

    -Tee-

    • Like 1

  7. I was curious does the compiled optimize out inhetiance that is needlesly added. Turns out it can't.

    Is there any technical reason that this is not possible, how Delphi classes work, or it is just missing optimization  from Delphi compiler.,

    My point here is that, if you care, remove unneeded in heritance from ytou code base. Effect is very small, most likely not even measurable, but do as you please.


    image.thumb.png.dfb685080aee7bb800a57bf770f9f471.png


    In very tight loopå this might be porblem, most cases not. Why someone would add those, is different discussion. Sometimes I add overridden method, because I think I need to do something in there, but I just forget to remove it later.

    Test project:

    unit Unit27;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    
    type
      TForm27 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
      TBaseClass = class(TObject)
      strict private
        FList: TStringList;
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo1 = class(TBaseClass)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo2 = class(TFoo1)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo3 = class(TFoo2)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo4 = class(TFoo3)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo5 = class(TFoo4)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo6 = class(TFoo5)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo7 = class(TFoo6)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo8 = class(TFoo7)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo9 = class(TFoo8)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
      TFoo10 = class(TFoo9)
      strict private
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
    var
      Form27: TForm27;
    
    implementation
    
    {$R *.dfm}
    
    uses
      System.Diagnostics;
    
    procedure TForm27.Button1Click(Sender: TObject);
    const
      LOOP_COUNT = 1_000_000;
    var
      LSW: TStopwatch;
    begin
      LSW := TStopwatch.StartNew;
      for var I := 1 to LOOP_COUNT do
      begin
        var LObject := TBaseClass.Create;
        LObject.Free;
      end;
      LSW.Stop;
      Memo1.Lines.Add('BaseClass: ' + FormatFloat('0.00', LSW.Elapsed.TotalMilliseconds) + ' ms');
    
      LSW := TStopwatch.StartNew;
      for var I := 1 to LOOP_COUNT do
      begin
        var LObject := TFoo10.Create;
        LObject.Free;
      end;
      LSW.Stop;
      Memo1.Lines.Add('unneeded inheritance: ' +  FormatFloat('0.00', LSW.Elapsed.TotalMilliseconds) + ' ms');
    end;
    
    procedure TForm27.FormCreate(Sender: TObject);
    begin
    
    end;
    
    { TBaseClass }
    
    constructor TBaseClass.Create;
    begin
      inherited Create;
    
      FList := TStringList.Create;
    end;
    
    destructor TBaseClass.Destroy;
    begin
      FList.Free;
    
      inherited Destroy;
    end;
    
    { TFoo9 }
    
    constructor TFoo9.Create;
    begin
      inherited Create;
    end;
    
    destructor TFoo9.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo1 }
    
    constructor TFoo1.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo1.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo2 }
    
    constructor TFoo2.Create;
    begin
      inherited Create;
    end;
    
    destructor TFoo2.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo3 }
    
    constructor TFoo3.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo3.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo4 }
    
    constructor TFoo4.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo4.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo5 }
    
    constructor TFoo5.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo5.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo6 }
    
    constructor TFoo6.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo6.Destroy;
    begin
    
      inherited Destroy;
    
    end;
    
    { TFoo7 }
    
    constructor TFoo7.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo7.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo8 }
    
    constructor TFoo8.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo8.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    { TFoo10 }
    
    constructor TFoo10.Create;
    begin
      inherited Create;
    
    end;
    
    destructor TFoo10.Destroy;
    begin
    
      inherited Destroy;
    end;
    
    end.

     


  8. 18 hours ago, FranzB said:

    is there any plan when this update will be available ?  Any first version available ...  in order to compile my existing windows code to UBUNTU .

    I think you need to fork, and make OTL work on ubuntu and make pull request, and hope it will be accepted.

    If Primoz don't use Linux him self, I think he has little interest to make it work on Linux, just for fun of it.

     

    -Tee-


  9. Or just "setter" method with original code.

    Something like...
     

    function SetFloatParameter(const ADataSet: TDataSet; const AParamName: string; const AValueOK: Boolean; const AFloatValue: Double);
    begin
      Result := False;
    
      if AValueOK then
      begin
        ADataSet.ParamByName(AParamName).AsFloat := AFloatValue;
        Result := True;
      end
      else
        ADataSet.ParamByName(AParamName).Clear;
    end;

     


  10. 7 hours ago, Alberto Paganini said:

    Hello,

     

    I am thinking of buying a mini PC and installing Delphi CE. I chose the mini PC mainly because of its small footprint.

    I am not a professional programmer, so I would not use it for 8+ hours every day. What do you recommend in terms of CPU, RAM, SDD size, etc.? Is it a good idea?

     

    Many thanks

    Alberto

    It depends quite a lot.

    But would go for I have and budget of xxx in my currency, what I can get with it. Ask people opinions about that, is it enough. And then decide to save more or purchase.


    I've been thinking of, if Company will get one, for my work computer.  Mainly because I need laptop as laptop (the screen) maybe once or twice a year. Also with price of decent laptop, you get way better mini-PC (in terms of performance etc...). Problem being, for corporate use, that there are no good options usually from popular brands, and brands that make good models don't have support and service options that companies need. I think... IF someone has better info, I would be more than happy to stand corrected on this...
     

    -Tee- 


  11. 4 hours ago, Jim McKeeth said:
    1. Manually reinstall the GetIt packages
      
      getitcmd -i=FmxLinux-12-1.78;ParnassusCoreEditor-12-1.6.4.1;CodeSite-5.4.4;AWSSDKforDelphi-12

       

    Dunno (first time heard about GetIT command line client), but would be nice be able to use wildards:

    getitcmd -i=FmxLinux*;ParnassusCoreEditor*;CodeSite*;AWSSDKforDelphi*

    or even:

    getitcmd -i=FmxLinux*;*Parnassus*;CodeSite*;AWSSDKforDelphi*

    PS.
      GetIT Seems to be down... Are the GetIT based installer and ISO installer compatible with each other. At least they used not to be??


  12. Helllo,

    Defining constants is pretty limited in delphi. some I think, related to single pass compiler.

    Latest was this case

      // Works
      MULTIPLIER = 1000;
      MULTIPLIED_CONSTANT = 1E-11 * MULTIPLIER;
      OTHER_FLOAT_CONSTANT: Double = 0.005;
    
      // Don't work
      MULTIPLIER: NativeInt = 1000;
      MULTIPLIED_CONSTANT = 1E-11 * MULTIPLIER; // <- E2026 Constant expression expected 

    This seems kind of weird.

    Is this limitation or bug in the Compiler, or feature I don't know about.

     

    -Tee-
     


  13. 11 hours ago, Remy Lebeau said:

    The existing OpenSSL code in the main Indy library is being pulled out into this new package for a v1.0 release for existing users, and then it will be updated with the latest OpenSSL APIs in subsequent releases, independent of the main Indy library.

    Will get merged to main someday?`Right?

    Quote

     But, there are other differences Embarcadero does make to Indy itself - most notably, the Packages are changed to use LIBSUFFIX, etc.

    Would it be better to get closer to the Embarcadero version, where possible, because every difference will cause some problems and confusion, I think. 

    Also it would make things easier for Embarcadero to merge fixes to their version. etc,... And finally the one with New OpenSSL-stuff...

    Just my 0.02€

    -tee-

×