Recent

Author Topic: Light LCL (LLCL) - Small Windows executable files v1.02  (Read 42067 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #45 on: November 30, 2015, 01:17:00 pm »
What does KOL stand for?
The Key Objects Library

http://kolmck.net/ (which I host and is the official website)
http://wiki.freepascal.org/KOL
http://wiki.freepascal.org/KOL-CE

It is  a complete framework like VCL or LCL (in the sense that you HAVE to choose one or the other ) for 32bit and 64bit Windows and well maintained. There is some unmaintained Linux as well, but frankly unusable. It is usable from Lazarus as well, although atm only with an older version.
« Last Edit: November 30, 2015, 01:25:21 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #46 on: November 30, 2015, 02:28:35 pm »
Besides TObject and Advanced Records there aren't other possibilities to speed up Object Pascal Classes?

First define a problem (narrowly), and then propose solutions. What is the problem with classes, what subset is allowed to speed it up?


Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #47 on: November 30, 2015, 03:02:55 pm »
This simple example  without any fancy testing creates 10.000.000 objects and classes and free's them again. Very crude, but you will get a considerable speed difference.
Illustrates  why object is still relevant. In Delphi the results are more dramatic
Code: Pascal  [Select][+][-]
  1. program objtest;
  2. {$IFDEF FPC}{$MODE DELPHI}{$H+}{$ENDIF}
  3. {$APPTYPE CONSOLE}
  4. uses
  5.   windows,sysutils;
  6.  
  7. type
  8.   TObj = object
  9.   end;
  10.   PObj = ^TObj;
  11.  
  12. var
  13.   i:integer;
  14.   O:PObj;
  15.   T:TObject;
  16.   Ti:TDateTime;
  17. begin
  18.   write('Classes: ');
  19.   Ti := GetTickCount;
  20.   for i:=0 to 10000000 do
  21.   begin
  22.     T := Tobject.Create;
  23.     Try
  24.       //
  25.     finally
  26.       T.Free;
  27.     end;
  28.   end;
  29.   writeln(GetTickCount - Ti :8 :8);
  30.   Sleep(100);
  31.   write('Objects: ');
  32.   Ti := GetTickCount;
  33.   for i:=0 to 10000000 do
  34.   begin
  35.     O := New(PObj);
  36.     Try
  37.       //
  38.     finally
  39.       Dispose(O);
  40.     end;
  41.   end;
  42.   writeln(GetTickCount - Ti :8 :8);
  43.   ReadLn;
  44. end.
  45. // Edit to gettickcount
  46.  

« Last Edit: November 30, 2015, 03:15:48 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #48 on: November 30, 2015, 03:14:39 pm »
This simple example  without any fancy testing creates 10.000.000 objects and classes and free's them again. Very crude, but you will get a considerable speed difference.

Yes, so ? That is probably because the sizeof(object)=0 and the new() probably bails out immediately without actually touching the heapmanager

While a fun fact to demonstrate that  benchmarking is like statistics and are biased by who made them (intentionally or not), for anything real it is useless.

« Last Edit: November 30, 2015, 03:16:38 pm by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #49 on: November 30, 2015, 03:21:26 pm »
The benchmark also holds true when used in real world scenario's, e.g. KOL with all its complexity.
Not only because of the memory allocation.
I agree that benchmarking is a bit off here. I suggest to test on application.
As I wrote: it is about the right structure for a solution, not that one is better than the other.
objects are faster, though. Always, compared to Classes given the same job to do.

But, I'll give the example something to do  O:-):
Code: Pascal  [Select][+][-]
  1. program objtest;
  2. {$IFDEF FPC}{$MODE DELPHI}{$H+}{$J+}{$ENDIF}
  3. {$APPTYPE CONSOLE}
  4. uses
  5.   windows,sysutils;
  6.  
  7. type
  8.   TObj = object
  9.   const Oops:integer = 0;
  10.   class procedure incOops;
  11.   end;
  12.   PObj = ^TObj;
  13.  
  14.   TSomeObject = class
  15.     const Oops:integer = 0;
  16.     class procedure incOops;
  17.   end;
  18.  
  19.   class procedure TObj.incOops;
  20.   begin
  21.    inc(Oops);
  22.   end;
  23.  
  24.   class procedure TSomeObject.incOops;
  25.   begin
  26.    inc(Oops);
  27.   end;
  28. var
  29.   i:integer;
  30.   O:PObj;
  31.   T:TSomeObject;
  32.   Ti:TDateTime;
  33. begin
  34.   write('Classes: ');
  35.   Ti := GetTickCount;
  36.   for i:=0 to 1000000 do
  37.   begin
  38.     T := TSomeobject.Create;
  39.     Try
  40.       T.incOops;
  41.     finally
  42.       T.Free;
  43.     end;
  44.   end;
  45.   writeln(GetTickCount - Ti :8 :8, ' ', T.Oops);
  46.   Sleep(100);
  47.   write('Objects: ');
  48.   Ti := GetTickCount;
  49.   for i:=0 to 1000000 do
  50.   begin
  51.     O := New(PObj);
  52.     Try
  53.       O.incOops;
  54.     finally
  55.       Dispose(O);
  56.     end;
  57.   end;
  58.   writeln(GetTickCount - Ti :8 :8 , ' ', O.Oops);
  59.   ReadLn;
  60. end.
  61.  
  62.  
« Last Edit: November 30, 2015, 03:48:54 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #50 on: December 06, 2015, 06:31:18 am »
@ChrisF and @Thaddy
Thank you very much, Now i know something regarding advantages / disadvantages of objects vs classes.

According to my previous experiences, I had tried to strip the source code from original author of LVCL but cannot managed to run the program, some sort of EClassError occured. According to my view, i am unable to locate the error. Please have a look to the below attachment.
Holiday season is online now. :-)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #51 on: December 06, 2015, 02:55:39 pm »
@Deepaak:

Extract of Classes.pas in the LLCL:
Code: Pascal  [Select][+][-]
  1. ...
  2. {$IFDEF FPC} {$PACKENUM 1} {$ENDIF}   // Mandatory if not in Delphi Mode
  3. ...

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #52 on: December 06, 2015, 03:16:13 pm »
@Deepaak:

Extract of Classes.pas in the LLCL:
Code: Pascal  [Select][+][-]
  1. ...
  2. {$IFDEF FPC} {$PACKENUM 1} {$ENDIF}   // Mandatory if not in Delphi Mode
  3. ...

This worked perfect, still form didn't show up, instead received Error;

Quote
Project LLCLTest raised exception class 'External: SIGSEGV' at address 4184CA
Holiday season is online now. :-)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #53 on: December 06, 2015, 03:42:54 pm »
The LVCL has never been compatible with Free Pascal. You must "port" it first.

Anyway, concerning your last error, replace the following code line in Graphics.pas (in "function TFont.GetHandle: integer;");
Quote
//      StrLCopy(lfFaceName,pointer(fName),high(lfFaceName));
      StrLCopy(lfFaceName,pchar(fName),high(lfFaceName));

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #54 on: December 06, 2015, 05:15:35 pm »
The LVCL has never been compatible with Free Pascal. You must "port" it first.

Yes you are right. Actually i want to strip the skeleton to very minimum. No extended features. Just
TApplication and TForm.

Code: Pascal  [Select][+][-]
  1. program LLCLTest;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   Forms, Unit2
  7.   { you can add units after this };
  8.  
  9. {$R *.res}
  10.  
  11. begin
  12.  
  13.   Application.Initialize;
  14.   Application.CreateForm(TForm2, Form2);
  15.   Application.Run;
  16. end.            
  17.  
  18.  

with normal forms with button, label and edit , so i am striping the code. But it seems that i have still very little knowledge in pascal programming.

After editing TFont.GetHandle program worked but with a black window with no response. Just as no events are ever fired.   :(

bit working now but windows don't receive close event notification. Form cannot be closed using close button, when maximizing the form, certain areas become black. Checking will update here
« Last Edit: December 06, 2015, 05:46:32 pm by Deepaak »
Holiday season is online now. :-)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #55 on: December 06, 2015, 07:42:31 pm »
Forms.pas

Quote
procedure WMClose(var Msg: TMsg); message WM_CLOSE;

Wrong: TMsg<>TMessage

Quote
if (Msg.wParam = WM_CLOSE) Then Begin

Not any chance (even with a TMessage)

useroflazarus

  • New Member
  • *
  • Posts: 23
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #56 on: December 06, 2015, 09:20:52 pm »
problem with TImage.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #57 on: December 06, 2015, 10:21:04 pm »
The Light LCL supports only "straight" bitmap images (i.e. bmp files; no .png, jpg ... files).

Extract of readme.txt:
Quote
. TPicture:
  Only BMP images are supported.

Though I guess supporting simple PNG files should be feasible.


Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #58 on: December 23, 2015, 05:54:00 am »
I want to change the LLCL.Classes to FPC.Classes but failed, because TPersistent class is totally different. Can it be changed to work with default fpc classes or not.
Holiday season is online now. :-)

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Light LCL (LLCL) - Small Windows executable files
« Reply #59 on: December 23, 2015, 05:28:30 pm »
As indicated in the documentation (see "README.txt", Chapter "6. GENERAL NOTES"), you can't use the standard (i.e. Delphi or FPC) "Classes.pas" unit.

At least, not without some modifications.

One of the samples provided, "GetWebPage" (https://github.com/FChrisF/LLCL-samples/tree/master/FPC/GetWebPage), is an illustration of how to modify the LLCL, in order to use the standard "Classes.pas" unit in your own code.

A small utility program, "LClassesMake", is provided with this sample. Compile it, then run the executable (it's a console program) in your sub-directory containing all the LLCL units.

Practically, after the modifications done by "LClassesMake" the LLCL "Classes.pas" file is renamed in "LClasses.pas", and all of the other LLCL units are then using it (i.e. LClasses), instead of the standard one (Classes).

 

TinyPortal © 2005-2018