Lazarus

Announcements => Third party => Topic started by: Pascal on November 17, 2017, 08:28:56 am

Title: LazProfiler (beta)
Post by: Pascal on November 17, 2017, 08:28:56 am
LazProfiler
One-Click-Profiling for Lazarus.

Wiki: http://wiki.freepascal.org/LazProfiler (http://wiki.freepascal.org/LazProfiler)

It's available on GitHub (https://github.com/PascalRiekenberg/LazProfiler/releases). It also needs VirtualTreeView and EpikTimer.

You need FPC and Lazarus trunk versions to be able to install it!
As it needs generics and additional PascalParser funktionality (FPC) and new IDE addon functions (Lazarus)

Bug reports, suggestions and feature requests are welcome.
Title: Re: LazProfiler (beta)
Post by: Imants on November 18, 2017, 11:01:00 pm
I do not think that this comand wil lever work for Linux users:

Code: Pascal  [Select][+][-]
  1. before_compile.cmd $(LazarusDir) $PkgDir(etpackage)epiktimer.pas
  2.  

Is this mandatory?

What it does?
Title: Re: LazProfiler (beta)
Post by: JuhaManninen on November 19, 2017, 12:33:38 am
Maybe a link should be added here:
 http://wiki.lazarus.freepascal.org/Profiling

Do you know about FPProfiler? How does your profiler compare with it?
 http://wiki.lazarus.freepascal.org/FPProfiler
Title: Re: LazProfiler (beta)
Post by: Pascal on November 19, 2017, 07:54:05 am
I do not think that this comand wil lever work for Linux users:

Code: Pascal  [Select][+][-]
  1. before_compile.cmd $(LazarusDir) $PkgDir(etpackage)epiktimer.pas
  2.  

Is this mandatory?

What it does?

It creates the resourcefile for the units used during profiling (runtime.lrs). They will be copied to the main directory and deleted after profiling.
The latest resource is included. So this is not needed. I will remove it from the options in the next version.

Many thanks for the hint.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 19, 2017, 07:56:22 am
Maybe a link should be added here:
 http://wiki.lazarus.freepascal.org/Profiling

I will do so.

Do you know about FPProfiler? How does your profiler compare with it?
 http://wiki.lazarus.freepascal.org/FPProfiler

It runs with one click. So you do not have to worry about instrumenting und unistrumenting your code.
Title: Re: LazProfiler (beta)
Post by: zoltanleo on November 19, 2017, 09:21:31 pm
Саn't to install r56436
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 05:51:07 am
Саn't to install r56436
What's the output of your message window? There you can see the compiler errors.
Title: Re: LazProfiler (beta)
Post by: zoltanleo on November 20, 2017, 07:07:16 am
What's the output of your message window? There you can see the compiler errors.
Code: Pascal  [Select][+][-]
  1. LazProfilerCore.pas(143,15) Error: Identifier not found "TList"

I suspect that the fpc version at me too old. Please, specify the minimum fpc version in requirements of installation
Title: Re: LazProfiler (beta)
Post by: molly on November 20, 2017, 07:21:26 am
What's the output of your message window? There you can see the compiler errors.
Code: Pascal  [Select][+][-]
  1. LazProfilerCore.pas(143,15) Error: Identifier not found "TList"

I suspect that the fpc version at me too old. Please, specify the minimum fpc version in requirements of installation
You need FPC and Lazarus trunk versions to be able to install it!
As it needs generics and addition PascalParser funktionality (FPC) and new IDE addon functions (Lazarus)

Seeing your tagline @zoltanleo you are already using trunk so it would probably be more efficient to ask about revision number. Then again, TList is a standard class that exists... well... since the beginning of time. I suspect you have other errors listed before that error or perhaps have a faulty installation.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 08:11:19 am
@zoltanleo: Maybe you should update FPC and Lazarus to latest revisions and try again.
Title: Re: LazProfiler (beta)
Post by: zoltanleo on November 20, 2017, 08:15:27 am
Seeing your tagline @zoltanleo you are already using trunk so it would probably be more efficient to ask about revision number. Then again, TList is a standard class that exists... well... since the beginning of time. I suspect you have other errors listed before that error or perhaps have a faulty installation.
It is difficult for me to assume other reasons. At present I have trunk fpc and IDE versions also (see my profile). I tried to establish by subj and a traditional way, and by means of Onlinepackagemanager.

I will establish the last audits of the compiler and Lazarus and I will try again.

I have only one request, specify number of the minimum audit fpc after which profiler can be established with guarantee  ;)

@zoltanleo: Maybe you should update FPC and Lazarus to latest revisions and try again.
Thanks for council. I and will arrive
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 08:24:26 am
I have only one request, specify number of the minimum audit fpc after which profiler can be established with guarantee  ;)

For Lazarus this is 56254 .
For FPC you need at least 37235.
Title: Re: LazProfiler (beta)
Post by: howardpc on November 20, 2017, 08:30:55 am
@zoltanleo
The sources also mention the minimum trunk revision needed.
Make sure that the package's "Execute before" entry is blank.
I used the OPM to try to install LazProfiler, and compilation failed for me. I had to open the package options, go to the Compiler Commands page and remove the "Execute before" Command.

@Pascal
Thanks for this excellent tool! Already the beta looks very promising.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 08:43:43 am
@Pascal
Thanks for this excellent tool! Already the beta looks very promising.

Pleased to hear :D
Title: Re: LazProfiler (beta)
Post by: zoltanleo on November 20, 2017, 09:57:23 am

For Lazarus this is 56254 .
For FPC you need at least 37235.

Thank U very much, friend  :)
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 11:12:01 am
Ok, be warned! It is a BETA!

Make a backup / spare copy of your "to profile" project sources before trying. I'm glad i did.

Installed and tried with latest trunk. All seams ok when profiling a "small" project. When i try a big project (> 100k lines) i get error 416, list index out of bounds. After that i am unable to reopen and or rebuild the project for normal running / debugging. Als also "Run > Cleanup profiler" does not work on the big project so the code is full of the added profiling enter and exit routines.

Anyone else getting a list index out of bounds?
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 11:23:00 am
Ok, be warned! It is a BETA!

Make a backup / spare copy of your "to profile" project sources before trying. I'm glad i did.

Installed and tried with latest trunk. All seams ok when profiling a "small" project. When i try a big project (> 100k lines) i get error 416, list index out of bounds. After that i am unable to reopen and or rebuild the project for normal running / debugging. Als also "Run > Cleanup profiler" does not work on the big project so the code is full of the added profiling enter and exit routines.

Anyone else getting a list index out of bounds?

Strange! I'm sorry you have had trouble with LazProfiler.
At least "Run > Cleanup profiler" should restore the original sources.
The original sources are renamed to original_filename.lazprofiler_backup at it's original positions.

Is your "big project" available to the public? Then i could test it here.

My biggest test project was about 64k lines.
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 12:09:18 pm
Sadly not, it's a commercial application i maintain for a client.

I will try later to find out where exactly the out of bounds is happening. The out of bounds happens when selecting the "Run > profile" before the actual compile cycle starts. The code in the project is nothing fancy, there's just a lot of it spread over multiple include folders.

I have included a small other project that also fails to profile. Its a small (audio) function generator using uos (you might need to download the portaudio dll's and place them in al "lib" subfolder where the compiled executable resides if you actually try to run it). See the function LoadAudio on line 94 of main.pas.

When doing "Run > Profile" this project fails somewhere in uos.pas after some comment. At least thats where the ide opens the file.
Title: Re: LazProfiler (beta)
Post by: JuhaManninen on November 20, 2017, 12:43:34 pm
Make sure that the package's "Execute before" entry is blank.
@Pascal, please remove the "Execute before" or change it so it compiles on Linux and other platforms.
This revealed also a usability problem with OpkMan. It does not allow opening the downloaded (broken) package in the IDE. Some of the toolbar buttons operate on selected packages but some don't. For example you would expect the "Open" button to open a selected package but it does not! Clearly there should be 2 visually separated toolbars.

@Pascal, you could also add "$(IDEBuildOptions)" to the compiler "Custom Options" of your package. Then it is built with the same debug flags as the IDE itself. It would allow people to send you backtraces of errors better. A backtrace may be enough to find a bug.
Actually Bram71 already has range check enabled as he got an "index out of bounds" error.
Anybody testing beta or development versions should enable all debug flags and checks.
Title: Re: LazProfiler (beta)
Post by: balazsszekely on November 20, 2017, 01:04:44 pm
@Juha
Quote
Some of the toolbar buttons operate on selected packages but some don't.
Not selected but checked packages.

Quote
For example you would expect the "Open" button to open a selected package but it does not! Clearly there should be 2 visually separated toolbars.
The "Open" tool button opens the local repository in the file manager.  Opening every checked package make no sense, what if somebody checks 25 package? OPM should open 25 explorer/file manager window?  If you wish to open the broken package in the IDE, you should close OPM and click the error on the message window. OPM is a modal window anyways, you cannot work with the IDE until is opened.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 01:28:54 pm
@GetMem: I uploaded an updated package. Could you please replace the old one?
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 01:31:22 pm
Make sure that the package's "Execute before" entry is blank.
@Pascal, please remove the "Execute before" or change it so it compiles on Linux and other platforms.

Done.

@Pascal, you could also add "$(IDEBuildOptions)" to the compiler "Custom Options" of your package. Then it is built with the same debug flags as the IDE itself. It would allow people to send you backtraces of errors better. A backtrace may be enough to find a bug.
Actually Bram71 already has range check enabled as he got an "index out of bounds" error.
Anybody testing beta or development versions should enable all debug flags and checks.

Also done!  Package has to be updated by GetMem.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 01:38:03 pm
Sadly not, it's a commercial application i maintain for a client.

I will try later to find out where exactly the out of bounds is happening. The out of bounds happens when selecting the "Run > profile" before the actual compile cycle starts. The code in the project is nothing fancy, there's just a lot of it spread over multiple include folders.

I have included a small other project that also fails to profile. Its a small (audio) function generator using uos (you might need to download the portaudio dll's and place them in al "lib" subfolder where the compiled executable resides if you actually try to run it). See the function LoadAudio on line 94 of main.pas.

When doing "Run > Profile" this project fails somewhere in uos.pas after some comment. At least thats where the ide opens the file.

The problem was that the runtime unit was added to an inactive define. Solved in 0.1.1.0

0.1.1.0 also keeps the sources instrumented if the build of the instrumented sources fail. Sources can be cleared with "Run > Cleanup Profiler" after studying the error.
Title: Re: LazProfiler (beta)
Post by: balazsszekely on November 20, 2017, 02:08:13 pm
Quote
@pascal
@GetMem: I uploaded an updated package. Could you please replace the old one?
Done.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 02:13:52 pm
Quote
@pascal
@GetMem: I uploaded an updated package. Could you please replace the old one?
Done.

Many thanks!
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 02:44:12 pm
Ok, tried again with the new package

The funcgen project now does not run when using "run > profile". I get a profile window wherein all routines are shown with a count of 0 (zero). Also the compiled binary does not run outside the ide. After using the normal "run > run f9" and the project is recompiled binary runs normally in and outside the ide. I also tried the big project again but that one still gives the out of bounds error.

I also noticed on this project (the first time i tried) that the profiler trips over wrong eof characters (visible after the end. in the ide). After removing the old (dos? / D7) eof chars i got to the point where it gives the out of bounds error.

This project also builds and runs normally with F9 with and with out debugging.

I test on a Ubuntu 16.04 xfce vm and normally build my projects for Windows & Linux 32/64 x86 and arm V7m. The test laz/fpc is build with FPCupDeluxe trunk updated yesterday.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 02:51:16 pm
I also noticed on this project (the first time i tried) that the profiler trips over wrong eof characters (visible after the end. in the ide). After removing the old (dos? / D7) eof chars i got to the point where it gives the out of bounds error.

Do you get the out of bounds error while instrumenting the sources or when the instrumented project runs?
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 03:05:35 pm
On the big project i get the error when instrumenting before anything in the messages window in the ide appears.

After that i am no longer able to open the project without the out of bounds error. I also have to restore the source from my backup because in a lot of files the LazProfilerRunTime is still in the uses sections. Checked again and there are no backup copies in the source folders.

After restore from my backup i can just build and run the project again. I checked if there where any file acces and or rights issues on the folders and that is not the case. Also all file names are in 8.3 format since its a project that has been a work in progress since Delphi 1...

On the little funcgen project i don't get any errors. It simply does not show its main form and appears to end without an exception after witch the profile window is shown with all the zero counts.
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 03:20:06 pm
I just created a small new test project with a single button.onclick handler adding some text to a memo and this project runs and profiles as expected.

So we can deduct that my installed lazarus, fpc and profiler are working and the cause of the problems i encounter are project / project settings specific.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 03:23:16 pm
On the big project i get the error when instrumenting before anything in the messages window in the ide appears.

After that i am no longer able to open the project without the out of bounds error. I also have to restore the source from my backup because in a lot of files the LazProfilerRunTime is still in the uses sections. Checked again and there are no backup copies in the source folders.

After restore from my backup i can just build and run the project again. I checked if there where any file acces and or rights issues on the folders and that is not the case. Also all file names are in 8.3 format since its a project that has been a work in progress since Delphi 1...

Okay, so there is a problem renaming the original files to *.lazprofiler_backup. That's why there are no backup copies.
I should check that before writing the instrumented source file!

project_executable.lazprofiler_setting is a csv file with all instrumented procedures/functions if it's available it will be loaded on opening a project.
Could you attach this file so i can test why it causes the out of bounds error on loading?
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 03:40:52 pm
Ok, will do.

I further tested the near empty test project and when adding cmem or cthreads to the project source the application won't start when profiling and you get the profiler screen with all the zero counts.
 
Title: Re: LazProfiler (beta)
Post by: Bram71 on November 20, 2017, 03:49:53 pm
Hmm,

The project_executable.lazprofiler_setting file does not get created for the big project so i think the error occurs before it is written to file. For the funcgen or test project it gets written (same output folder).
Title: Re: LazProfiler (beta)
Post by: JuhaManninen on November 20, 2017, 03:57:53 pm
@GetMem: I uploaded an updated package. Could you please replace the old one?
Also done!  Package has to be updated by GetMem.
@Pascal, where are the original sources kept? There is some revision control system, right?
Your initial announcement only mentions the Online Package Manager repository as a download source.
I have a feeling you misuse the OpkMan and its admin GetMem as a revision control system. If so, then you have seriously misunderstood its purpose. It is meant for released packages. The actual development before a release must happen somewhere else.
GitHub seems to be the fashion of today but there are plenty of other good choices, too.

GetMem, please guide people when they misuse your OpkMan.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 20, 2017, 04:08:13 pm
@GetMem: I uploaded an updated package. Could you please replace the old one?
Also done!  Package has to be updated by GetMem.
@Pascal, where are the original sources kept? There is some revision control system, right?
Your initial announcement only mentions the Online Package Manager repository as a download source.
I have a feeling you misuse the OpkMan and its admin GetMem as a revision control system. If so, then you have seriously misunderstood its purpose. It is meant for released packages. The actual development before a release must happen somewhere else.
GitHub seems to be the fashion of today but there are plenty of other good choices, too.

GetMem, please guide people when they misuse your OpkMan.

I kindly asked GetMem if he is willing to add test(alpha/beta) versions, which he affirmed.
But you are right, i should set up a GitHub repo for this.

@GetMem: If it's okay to you, i've uploaded an updated version. If not, no matter.
Title: Re: LazProfiler (beta)
Post by: JuhaManninen on November 20, 2017, 06:00:39 pm
But you are right, i should set up a GitHub repo for this.
Lazarus CCR is also a valid option. It has got a bad reputation because many of its projects' authors have fled. For the active maintainers however Subversion and the repository itself work very well.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 21, 2017, 06:25:57 am
New release:
LazProfiler 0.1.2.0: (https://github.com/PascalRiekenberg/LazProfiler/releases/download/0.1.2.0/lazprofiler_0.1.2.0.zip)
- fixed: checks if backup of source was successfully created before writing instrumented source to original file
Title: Re: LazProfiler (beta)
Post by: avra on November 21, 2017, 08:23:58 am
Sources can be cleared with "Run > Cleanup Profiler" after studying the error.
Reading something like "Run > Cleanup Profiler and restore original files" would be more informative for me. If I didn't read it I would not link original message to restoring project files. What do you think? Any better idea?
Title: Re: LazProfiler (beta)
Post by: Pascal on November 21, 2017, 08:48:34 am
Sources can be cleared with "Run > Cleanup Profiler" after studying the error.
Reading something like "Run > Cleanup Profiler and restore original files" would be more informative for me. If I didn't read it I would not link original message to restoring project files. What do you think? Any better idea?

Yes, why not. I will cahnge it in next release.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 21, 2017, 09:09:47 am
Ok, will do.

I further tested the near empty test project and when adding cmem or cthreads to the project source the application won't start when profiling and you get the profiler screen with all the zero counts.

These are Unix specific, aren't they? I have no clue what happens to the program when you add these units. I've never used Lazarus/FPC on Unix.
Title: Re: LazProfiler (beta)
Post by: Pascal on November 22, 2017, 10:32:34 am
Hmm,

The project_executable.lazprofiler_setting file does not get created for the big project so i think the error occurs before it is written to file. For the funcgen or test project it gets written (same output folder).

Could you test 0.1.2.0, please. It should not write instrumented files if backup of original source fails.
Title: Re: LazProfiler (beta)
Post by: Pascal on September 24, 2018, 11:28:53 am
New release:
LazProfiler 0.1.3.0: (https://github.com/PascalRiekenberg/LazProfiler/archive/0.1.3.0.zip)
- renamed menu entries
- include IncludePath. Patch by zamtmn.
- minor refactoring
- fixed recognition of declared record in procedure var section
- fixed memory leaks
Title: Re: LazProfiler (beta)
Post by: howardpc on September 24, 2018, 12:45:22 pm
Thanks for the ingenuity and work that you have put into this, and for sharing the update. This is an impressive tool.
However, on Linux, I could only get it to compile by removing the "before compile" command. Which does not seem to affect functionality after very limited testing.
Title: Re: LazProfiler (beta)
Post by: Pascal on September 24, 2018, 01:56:59 pm
Thanks for the ingenuity and work that you have put into this, and for sharing the update. This is an impressive tool.

Thanks, you are welcome.

However, on Linux, I could only get it to compile by removing the "before compile" command. Which does not seem to affect functionality after very limited testing.

It only creats the runtime.lrs with the needed sources (LazProfilerRunTime.pas, LazProfilerCore.pas and epiktimer.pas).
It's only needed if you modify these sources.
Title: Re: LazProfiler (beta)
Post by: Pascal on September 24, 2018, 02:12:48 pm
However, on Linux, I could only get it to compile by removing the "before compile" command. Which does not seem to affect functionality after very limited testing.

It only creats the runtime.lrs with the needed sources (LazProfilerRunTime.pas, LazProfilerCore.pas and epiktimer.pas).
It's only needed if you modify these sources.

I just tired to replace the "Before compile" command to:
Code: Text  [Select][+][-]
  1. $(LazarusDir)/tools/lazres runtime.lrs "LazProfilerRunTime.pas"=rt "LazProfilerCore.pas"=core "$PkgDir(etpackage)epiktimer.pas"=timer

It works on Windows. Can you give it a try on Linux?
Title: Re: LazProfiler (beta)
Post by: howardpc on September 24, 2018, 02:55:27 pm
Yes, I tried that replacement command, and it works fine on Linux (Mint).
(Earlier the compilation failure message I got pointed to a missing LazProfiler.compiled file, which (before any package compilation) seemed bound to be a file that would not be found).
Title: Re: LazProfiler (beta)
Post by: Pascal on September 24, 2018, 03:10:24 pm
Yes, I tried that replacement command, and it works fine on Linux (Mint).

Fine, thanks.

---

I am currently working on making selection and deselection of procedures/functions for instrumenting much easier,
so that you can disable complete units or classes.
Title: Re: LazProfiler (beta)
Post by: zamtmn on September 25, 2018, 11:41:15 am
>>Anyone else getting a list index out of bounds?
Yes. I have "List index 82 out of bounds" with https://github.com/zamtmn/zcad project
Title: Re: LazProfiler (beta)
Post by: zamtmn on September 25, 2018, 07:47:04 pm
We need CallGraph like http://wiki.lazarus.freepascal.org/File:Fpprofiler_callgraph.png
Title: Re: LazProfiler (beta)
Post by: Pascal on September 26, 2018, 05:49:53 am
>>Anyone else getting a list index out of bounds?
Yes. I have "List index 82 out of bounds" with https://github.com/zamtmn/zcad project

Fine! I'll have a look.
Title: Re: LazProfiler (beta)
Post by: Pascal on September 26, 2018, 05:50:38 am
We need CallGraph like http://wiki.lazarus.freepascal.org/File:Fpprofiler_callgraph.png

It's on my todo list already.
Title: Re: LazProfiler (beta)
Post by: Pascal on September 26, 2018, 09:58:37 am
>>Anyone else getting a list index out of bounds?
Yes. I have "List index 82 out of bounds" with https://github.com/zamtmn/zcad project

Fine! I'll have a look.

Found the problem. I do not handle includes correctly! Working on fix...
Title: Re: LazProfiler (beta)
Post by: Pascal on September 30, 2018, 12:22:34 pm
New release:
LazProfiler 0.2.0.0: (https://github.com/PascalRiekenberg/LazProfiler/archive/0.2.0.0.zip)
- new Result-TreeView
  - group by Unit
  - group by Object
- fixed include handling
- last group and sort column and order is saved to settings file now
- refactoring
Title: Re: LazProfiler (beta)
Post by: Pascal on October 01, 2018, 07:39:44 am
>>Anyone else getting a list index out of bounds?
Yes. I have "List index 82 out of bounds" with https://github.com/zamtmn/zcad project
I used ZCad for testing. Many thanks. I already found some problems and corrected them in 0.2.0.0

One issue is still left: The packages are missing the LazProfiler runtime sources to build.
Just disable the package units for profiling and you are able to profile ZCad. To do this just
press the "Unit" header of the "Profiler Result" window and check/uncheck individual units.
Title: Re: LazProfiler (beta)
Post by: zamtmn on October 01, 2018, 11:08:39 am
Thanks!
But I cannot use last version. Nothing happens, the results window is empty. Maybe it's a problem on my side.
Title: Re: LazProfiler (beta)
Post by: Pascal on October 01, 2018, 11:28:57 am
I just updated the repo. New release will follow.
You are now able to profile ZCad. No additional steps necessary.
To be safe you should delete the settings file "cad/zcad.lazprofiler_setting" before starting Lazarus.
Title: Re: LazProfiler (beta)
Post by: Pascal on October 01, 2018, 11:54:34 am
Just did a quick test:
Title: Re: LazProfiler (beta)
Post by: zamtmn on October 01, 2018, 12:08:54 pm
Yes, it works!

It remains to add some settings, call graph... and we'll bury AQTime))

Thanks!
Title: Re: LazProfiler (beta)
Post by: Pascal on October 01, 2018, 08:40:24 pm
New release:
LazProfiler 0.2.1.0: (https://github.com/PascalRiekenberg/LazProfiler/archive/0.2.1.0.zip)
- fixed recursive directory scan
- do not scan include path
- ignore units belonging to packages
- fixed memory leak
Title: Re: LazProfiler (beta)
Post by: AlexTP on January 24, 2019, 02:11:29 pm
FPC 3.3.1, Lazarus trunk. Project CudaText (see wiki link in my post).
On doing Profile i got such broken code of main form

EDITED
bug is fixed in the last release.
Title: Re: LazProfiler (beta)
Post by: AlexTP on January 24, 2019, 02:19:10 pm
And this.
I cannot profile my component ATSynEdit (wiki link in the post):
I added to file atsynedit.pas
Code: Pascal  [Select][+][-]
  1. procedure TATSynEdit.Paint;
  2. begin
  3.   if not HandleAllocated then exit;
  4.   // start-profiler
  5.   PaintEx(-1);
  6.   // stop-profiler
  7. end;
  8.  

but still don't see results for Paint in the Profiler output. I did run the demo_editor project.
Title: Re: LazProfiler (beta)
Post by: AlexTP on January 26, 2019, 12:50:41 pm
For ATSynEdit, I need to profile all methods of ATSynEdit class and other used subclasses: TATStrings, TATCarets, TATMarkers etc etc. Some kind of work needed to specify which classes or which packages.
Title: Re: LazProfiler (beta)
Post by: Pascal on March 04, 2019, 08:40:07 pm
Yes, at the moment packages are completely ignored, as i have to modify the package setting so that it finds LazProfilerCore unit, or i have to copy the unit to the package folder.

I am working on this. It's a good testbed for LazProfiler! I already found some bugs in conjunction with ATSynEdit in profiling code!

I'll keep you updated.
Title: Re: LazProfiler (beta)
Post by: AlexTP on March 05, 2019, 07:17:00 am
Thanks, I will wait for new version.
Title: Re: LazProfiler (beta)
Post by: Pascal on March 13, 2019, 03:46:30 pm
I'm making progress:
Title: Re: LazProfiler (beta)
Post by: Pascal on March 19, 2019, 11:23:41 am
New release:
LazProfiler 0.3.0.0: (https://github.com/PascalRiekenberg/LazProfiler/archive/0.3.0.0.zip)
- profiling of packages (only if outside of Lazarus source directory)
- renamed columns "Net" -> "Σ Net", "Gross" -> "Σ Gross"
- new columns: "% Net", "% Gross", "Ø Net", "Ø Gross"
- fixed parsing of operator functions
- fixed parsing of "START-PROFILER" and "STOP-PROFILER" if inside un-instrumented procedure/function
- Activation of LazProfiler (default is inactive)

Needs Lazarus trunk r60719 and fpc trunk (at least fixes_3_2)
Title: Re: LazProfiler (beta)
Post by: AlexTP on March 19, 2019, 06:32:59 pm
Very good, thanks. Will test later in component.
Title: Re: LazProfiler (beta)
Post by: howardpc on March 19, 2019, 08:27:18 pm
I get the error shown.
What do you think I am doing wrong?
Title: Re: LazProfiler (beta)
Post by: Pascal on March 20, 2019, 07:56:42 am
I get the error shown.
What do you think I am doing wrong?

Nothing! My fault. The path of the temorary unit output directory is not constructed in a cross platform manner. And as i have no
possibility to test on unix i didn't notice this bug.

Please test latest commit to repository.
Title: Re: LazProfiler (beta)
Post by: CCRDude on March 25, 2019, 12:25:44 pm
Bug reports, suggestions and feature requests are welcome.

Not sure how exactly your profiler works, but one feature would be absolutely great for me: if it could output a code coverage report!

A year ago, I tried to copy the code coverage feature from phpunit. To sum it up: this can help to verify that test code covers all methods or even lines that should be tested. My approach works (https://gitlab.com/ccrdude/laz-codecoverage-helper), but is way too slow for line-based reports.

Could LazProfiler report results by line, or is it method based only?
Title: Re: LazProfiler (beta)
Post by: Pascal on March 25, 2019, 04:05:44 pm
Bug reports, suggestions and feature requests are welcome.

Not sure how exactly your profiler works, but one feature would be absolutely great for me: if it could output a code coverage report!

A year ago, I tried to copy the code coverage feature from phpunit. To sum it up: this can help to verify that test code covers all methods or even lines that should be tested. My approach works (https://gitlab.com/ccrdude/laz-codecoverage-helper), but is way too slow for line-based reports.

Could LazProfiler report results by line, or is it method based only?

Sorry, LazProfiler is indeed method based.
Title: Re: LazProfiler (beta)
Post by: Pascal on April 01, 2019, 09:30:08 pm
Very good, thanks. Will test later in component.

Did you manage test latest release? Satisfied?
Title: Re: LazProfiler (beta)
Post by: K155LA3 on June 24, 2019, 08:56:46 pm
After installation, the error appears: "File not open". This error occurs when the "WriteLn (...") command is executed in LazProfilerAddon.pas and LazProfilerCore.pas. After commenting out these lines, this error message no longer appears.
Title: Re: LazProfiler (beta)
Post by: Fahmy Rofiq on December 31, 2019, 07:48:34 am
Please Help...
LazProfiler error when using ZeosDBO component.
Title: Re: LazProfiler (beta)
Post by: apeoperaio on July 08, 2020, 01:41:45 pm
Will LazProfiler be available with Lazarus 2.0.10 (FPC 3.2.0)?
Title: Re: LazProfiler (beta)
Post by: Fahmy Rofiq on August 09, 2020, 06:13:15 pm
Still doesnt work with current Trunk
Title: Re: LazProfiler (beta)
Post by: El Salvador on December 30, 2020, 05:00:10 pm
Will LazProfiler be available with Lazarus 2.0.10 (FPC 3.2.0)?
It is broken. I comment all writeln to avoid error message in opening project, but TPascalScanner will raise 'No support for resources of type "%s"' (.lfm or .res).
Title: Re: LazProfiler (beta)
Post by: PascalDragon on December 30, 2020, 05:40:58 pm
You need to add po_IgnoreUnknownResource to the scanner's Options property.
Title: Re: LazProfiler (beta)
Post by: El Salvador on December 30, 2020, 05:54:03 pm
So, I need use FPC Trunk version, right? Thanks.
Title: Re: LazProfiler (beta)
Post by: olly on May 06, 2021, 02:45:49 am
PR here.
https://github.com/PascalRiekenberg/LazProfiler/pull/4

Works on trunk laz&fpc fine.
Title: Re: LazProfiler (beta)
Post by: BosseB on October 04, 2021, 08:12:28 am
I came here from the FreePascal wiki LazProfiler page (https://wiki.freepascal.org/LazProfiler) and I am being warned by the forum to not comment since there has been no post for 120 days...
But this is clearly the support page for LazProfiler, right?

So I would like to get some usage help:

1- Does this work on Lazarus 2.0.12 and FPC 3.2.0 in ARM Linux (Raspberry Pi)?
I see requirements like these:
FPC trunk (needs generics and additional PascalParser funktionality) or fixes_3_2
Lazarus trunk (revision 60719 and above) or fixes_2_0
But I am using tagged releases 2.0.12 and 3.2.0, will that not work?
Lazarus Help/About states revision 64944

2- Does LazProfiler work for a command line program (no GUI parts) running as a systemd service?

3- I need the profiler in order to find why my application when running idle still eats 10% CPU on Linux.
Can this be done? There is no memory usage problem just the fact that it sits at 10% CPU while just waiting.

The application is running a TCP service so a user can connect to it using  a custom application in order to configure its operations and download data. It is meant to be used as a systemd service but can be started manually on the command line as well.
The application is itself a scheduler for measurement operations configured to start at certain times and run with certain job data used by an attached instrument (by RS232).
When it is waiting for a client connection or the time to start a measurement operation it should idle at close to 0% CPU usage but in fact it uses 10% as shown by the top command.
I need to find where this happens....

The application was ported from Delphi 2007 into FPC using Lazarus.
Title: Re: LazProfiler (beta)
Post by: lainz on December 26, 2022, 11:36:09 pm
Hi, this is still maintained?

On FPC 3.2.2 Lazarus 2.2.4 doesn't works, it gives an error when opening a lpi file or a form.
Title: Re: LazProfiler (beta)
Post by: simone on February 15, 2023, 03:37:24 pm
I'm very interested in this project. In the absence of a response about its status, I try to wake up the thread. I hope the author, who is a forum member and did a great job, can reply. Thanks in advance.
Title: Re: LazProfiler (beta)
Post by: lainz on February 15, 2023, 09:25:26 pm
I'm very interested in this project. In the absence of a response about its status, I try to wake up the thread. I hope the author, who is a forum member and did a great job, can reply. Thanks in advance.

I contacted him by PM and he says that is open to new pull requests to fix the code.
Title: Re: LazProfiler (beta)
Post by: Okoba on March 19, 2023, 10:43:30 am
@AlexTP do you still use LazProfiler? If yes, did you made some changes available to share?
I don't know if it will be useful for me or not, but I tried to make it work with latest of Lazarus, too many errors, WriteLn and other problems.
Title: Re: LazProfiler (beta)
Post by: AlexTP on March 19, 2023, 10:50:16 am
I was not able to use LazProfiler (was not able to measure function times), and did not make changes.
Title: Re: LazProfiler (beta)
Post by: Okoba on March 19, 2023, 10:51:19 am
Thank you. Do you use any profiler for CudaText?
Title: Re: LazProfiler (beta)
Post by: AlexTP on March 19, 2023, 11:12:42 am
I do not; the optimizations of CudaText is done by looking where app 'hangs' on handling huge documents. I use 'Pause execution' and see 'call stack'.
Title: Re: LazProfiler (beta)
Post by: Okoba on March 19, 2023, 11:17:50 am
Pause execution?
Title: Re: LazProfiler (beta)
Post by: AlexTP on March 19, 2023, 12:23:52 pm
IDE has the "Pause" button on toolbar, near "Run" button.
Title: Re: LazProfiler (beta)
Post by: Okoba on March 19, 2023, 01:30:13 pm
Thank you so much.
TinyPortal © 2005-2018