As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I recently upgraded from Delphi 4 to Delphi 2009. With Delphi 4 I had been using GpProfile by Primoz Gabrijelcic as a profiler and Memory Sleuth by Turbo Power for memory analysis and leak debugging. Both worked well for me. But I now need new tools that will work with Delphi 2009.
The leader in Profiling/Analysis tools for Delphi by a wide margin is obviously AQTime by AutomatedQA. They recently even gobbled up Memproof by Atanas Soyanov, which I understood was an excellent and free memory analysis tool, and incorporated its functionality into AQTime. But AQTime is very expensive for an individual programmer. It actually costs more than the upgrade to Delphi 2009 cost!
So my question is: Are there other less expensive options to do profiling and memory analysis in current versions of Delphi that you are happy with and recommend, or should I bite the bullet and pay the big bucks for AQTime?
Addenum: It seems the early answerers are indicating that the FastMM manager already included in Delphi is very good for finding memory leaks.
So then, are there any good alternatives for source code profiling?
One I'm curious about is ProDelphi by Michael Adolph which is less than one sixth the cost of AQTime. Do you use it? Is AQTime worth paying six times as much?
Addenum 2: I downloaded trial versions of both AQTime and ProDelphi.
AQTime was a bit overwhelming and a little confusing at first. It took a few hours to find some of the tricks needed to hook it up.
ProDelphi was very much like the GpProfile that I was used to. But its windows are cluttered and confusing and it's not quite as nice as GpProfile.
To me the big differences seem to be:
ProDelphi changes your code. AQTime does not. Changing code may corrupt your data if something goes wrong, but my experience with GpProfile was that it never happened to me. Plus one for AQTime.
ProDelphi requires you turn optimization off. But what you want to profile is your program with optimization on, the way it will be run. Plus one for AQTime.
ProDelphi only can profile down to the function or procedure. AQTime can go down to individual lines. Plus 2 for AQTime.
ProDelphi has a free version that will profile 20 routines, and its pro version costs less than $100 USD. AQTime is $600 USD. Plus 4 for ProDelphi.
The score is now 4-4. What do you think?
Addenum 3: Primoz Gabrijelcic is planning to get GpProfile working again. See his comments on some of the responses below. He on StackOverflow as Gabr.
Addenum 4: It seems like there may be a profiler solution after all. See Andre's open source asmprofiler, described below.
For the price, you cannot beat FastMM4 as a memory tracker. It's simple to use yet powerful and well integrated with Delphi.
I guess that you know that, without downloading, installing or changing anything else, just putting this line
ReportMemoryLeaksOnShutDown := True;
anywhere in your code, will enable basic reporting of memory leaks.
If you need more like crash information, EurekaLog is a very good product that we use. MadExcept also has a good reputation...
For profiling specifically, we have AQTime.
As for gpProfile, you can try and bug gabr on SO for an update... or go and update gpProfile yourself as it is open source. ;-)
I've made an open source profiler for Delphi:
http://code.google.com/p/asmprofiler/
It's not perfect, but it's free and open source :-).
The main reason I made it was because I missed an exact call tree.
For example, ProDelphi only stores a summary and total counts of all calls,
you cannot see what calls a specific procedure at a specific time did (or time
duration).
And it has a time chart, so you can see how the call duration changed over time.
Also take a Look at Eric Grange's Sampling Profiler
I've been very happy with AQtime for profiling.
Having used both GpProfile and AQTime I have found both to be effective at finding what method call is causing a bottle neck.
However AQTime can also tell me what line of code is causing this, without making any changes to my source code (although it works best with TD32 debugging and debug dcus).
I recently used it to speed up a routine by about 30x (due to bad use of a internal library function)
However I didn't have to pay for it myself!
We use AQTime Pro and are happy with it. Smartbear have recently released a completely free AQTime standard edition. Most of the features are still there but they have of course removed a bit
I agree with you about the interface of ProDelphi, but it does a good enough job that we're happy to stay with it. We only need to profile very occasionally when we have a significant performance issue, and it's always helped us find the problem pretty quickly. Very good value for money, and Michael seems pretty good about keeping it updated for new versions.
One thing I would suggest is that because it does require code to be inserted, having all the relevant code in some kind of VCS is invaluable. When we need to profile, we:
Check all relevant files in
Check them all out
Do the profiling we need, then
Cancel all checkouts, effectively rolling back to where we were.
Has anyone tried the Profiler component at Delphi Area? It is freeware with source and it's writeup says:
If you are looking for an easy and
accurate way to measure execution time
of your code for free, TProfiler is
what you need. TProfiler is a
non-visual and debugging component
that enables you to create named
timers in your code.
Each timer of TProfiler provides the
following information:
The number of times that the timer was
activated (Hit Count) The total
execution time The average execution
time on each hit Execution time on
the first hit Execution time on the
last hit The hit with minimum
execution time The hit with maximum
execution time
It's true, for profiling I miss Primoz' GpProfile, and haven't found a good replacement. I once tried AQTime, but wasn't too happy with it for the price.
For tracking of memory leaks and dodgy memory accesses however I couldn't be happier than I am with FastMM4.
I've been using ProDelphi for a long time & find it meets my needs.
I've been able to achieve stunning results in system performance improvements by using the data it provides.
For small projects the free version is fine.
For larger projects, you'll need the (Paid) pro version.
For a profiler you might try SmartInspect from Gurock Software. I never used GpProfile, but quickly glancing at its feature set reminded me of SmartInspect. Interestingly it doesn't claim to be a profiler, but it seems to be as much of one as GpProfile (unless I am missing something). It supports Delphi 2009 and has a free Trial and is a little cheaper then AQTime.
Note: SmartInspect is a logger rather than a profiler.
The FastMM4 memory manager mentioned in this older answer ("How to monitor or visualize memory fragmentation of a delphi application") keeps a list of all allocations which can be queried at run time (and displayed in a grid using the included demo application). It does not exactly show which object leaks, as the statistics are per block size. But it can be useful for long-time monitoring of applications in production, for example servers or services. I am currently integrating it in a (commercial) web application server framework as the 'VisualMM' add-on.
Related
I'm looking for some tools to improve my Delphi development.
And a tool that I could not found any free project is a benchmark tool.
Some one have some hit about some project to use ?
Today to check where I must focus my optimizations I use sample profiling, but it's not enough
I must file the function that spent more time overage, not just the top called functions.
Tks
I think the acknowledged leader in this field is AQtime.
If you have no money then you can try Sampling Profiler.
I'm sure others will be along in due course to offer yet more suggestions!
Check out my question on Profiler and Memory Analysis Tools for Delphi. In my Addenum 4, I mention André's Open Source Profiler for Delphi called AsmProfiler that he made. See his answer to that question that led me to it.
I had downloaded it and tried it and it is quite good. It is an instrumenting profiler like AQTime, so it may be better than a Sampling Profiler for certain optimizations. It does procedure-based timings, so the one thing it can't do that AQTime is line-by-line based timings. But for a free program that works well, most often procedure-based timings are good enough. I had used GpProfile very productively for many years which was very similar but it is no longer available for current versions of Delphi.
I see the following means of debugging and wonder if there are others or which FOSS tools a small company can use (we don't do much Windows programming).
1 Debug in the IDE, by setting breakpoints, using watches, etc
2 Debug in the IDE, by using the Event Log
I got some good info from this page and tweaked it to add timestamps and indent/outdent on procedure call/return, so that I can see nested calls more quickly. Does anyone know of anything better ?
3 Using a profiler
4 Any others?
Such as MadExcept, etc?
(I am currently using Delphi 7)
The Delphi integrated debugger is powerful enough, even in Delphi 7, to handle most debugging tasks. It can also debug an application remotely. Anyway, there are situations where you may need to track different kind of issue:
To check for memory leaks, you can switch to a memory manager like FastMM4 which has good memory leak reporting. Profilers like AQTime have also memory allocation profilers to identify such kind of issues.
To investigate performance problems, you need a performance profiler. There are sampling profilers (less invasive, although may be less precise) and standard profilers (AQTime again, not cheap but very good, and others).
To trace exception, especially on deployed applications, you may need tools like JCL/JVCL (free), MadExcept or EurekaLog or SmartInspect
To obtain a log of what the application does, you can use OutputDebugString() and the IDE event viewer, or the DebugView standalone application. There are also dedicated tools like SmartInspect.
You can also convert Delphi 7 .map files to .dbg files and use an external debugger as the WinSDK WinDbg, and look at application calls in tools like ProcessExplorer
Some debugging tools may also offer features like code coverage checks (which code was actually executed, and which was never), platform compliance (check API calls are supported by a given platform), resources use and so on, but may be useful for larger developments.
Delphi 7's IDE is pretty good to start with, only look at 3rd party tools if you run into something you can't fix with what you've got:
It's error messages are informative and not excessively verbose.
The debugger is pretty good, you've got lots of options for inspecting variables, brakepoints, conditional brakepoints, data brakepoints, address brakepoint, module load brakepoint. It's call-stack view is good, it has some support for multi-threaded debugging.
Good step-by-step execution, step into, step over, run until return, etc.
3rd party tools help when you need to diagnose a problem on the client's computer (you have no Delphi IDE on the client's computer). If you can get the problem to manifest on your computer you get away with the IDE alone, no need for any addition, free or payed for.
Profiler: That's not a debugging tool. You use an profiler when you need to find bottlenecks in your application, or you need to do some speed optimizations.
Logging 3rd party frameworks: The good ones are not cheap, and you can do minimal logging without a tool (even ShowMessage works some times).
MadExcept, other tools that log exceptions: They usually require debugging information to be present in the EXE, and that's not a good idea because it makes the program slower AND it easier to hack. Again, if you can get the exception on your machine, you don't need the logger.
I'm not saying 3rd party debugging aids are not useful: they are, but I'd wait until I can clearly see the benefit of any tool before I commit to it. And in my opinion there's no such thing as free software: Even the software you don't pay for requires time to learn how to use it and requires changes to your programs and workflow.
For the bigger work, there is AQTime.
A cheaper solution for selected code is running it through Free Pascal (with the "randomize local variables option") and run it through valgrind. I've validated most my streaming code (which heavily has backwards compat constructs) that way.
Another such interesting switch is -CR, verify object method call. It basically turns every
TXXX(something).callsomething
into
if something is txx then
TXXX(something).callsomething
else
raise some exception;
Specially in code with complex trees this can give some precious information.
Normal Pascal language checking (Range, I/O, Overflow, sTack aka -Criot) can be useful too, and is also available in Delphi.
Some range check errors (often loop bounderies) that can be detected statically, will result in compile errors in (beta) FPC 3.0.x+.
You can try the "Process Stack Viewer" of my (open source) sampling profiler:
http://code.google.com/p/asmprofiler/wiki/ProcessStackViewer
(you need some debug info: a .map or .jdbg file)
You can watch the stack (also the raw stack, with "false positives" but useful when normal stack walking is not possible) of all threads, and do some simple sampling profiling.
Note: My (older) instrumenting profiler does exact profiling, is on the same site.
Not sure why you would want to upgrade to debug a problem. Yes the newer IDE's provide more features to help you debug something, but taking into consideration your previous question on how to debug your program when it hangs, I'd sooner suggest a good logging solution like CodeSite or SmartInspect. They provide way more flexibility and features than any home-grown solution based around the event log and do not require you to step through the code, like the IDE does (which affects timings in multi-threadeded problems).
Update
Sorry, didn't get that FOSS stands for Free and Open Source Software. CodeSite and SmartInspect are neither. For a free solution, you could have a look though at the logging features within the Jedi family of tools.
Rad Studio XE includes a light version of CodeSite, and AQTime, which together are both compelling improvements.
You could do a lot with JCL Debug, MadExcept, and other profiling and logging tools, but CodeSite and AQTime are the two best for their respective tasks.
While working on my code lately, I've noticed that some of the memory usage is going up significantly, and I can't see many reasons for it in my code. So I'm wondering if there are any programs, techniques, or other types of tools that can scan my code (Delphi) and estimate for me what procedures, functions, and functions will be the heaviest memory users. Ideally, I' think I'd be looking at the code as it is run in debug mode, but if something can scan the source files and tell me, that would be even better. Thanks.
The type of tool you are looking for is a Profiler. There are lots of good profilers out there for most languages. I'm less familiar with Delphi though so I used google and it turned the following options
http://www.prodelphi.de/
http://delphitools.info/
But the best information seems to be on this question from StackOverflow
Delphi Profiling tools
See my answer to a similar question:
Memory profiling tool for Delphi?
Without knowing how you are currently measuring "memory use" it's difficult to say what might be the best tools to use.
We have used AQTime in the past it found a load of memory leaks.
http://www.automatedqa.com/products/aqtime/
another good Delphi tool is Eurekalog
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am having some performance problems with my Delphi 2006 app.
Can you Suggest any profiling tools that will help me find the bottle neck
i.e. A tool like turbo Profiler
I asked the same question not too long ago
I've downloaded and tried AQtime. It does seem comprehensive, but it is not an easy to use tool and is VERY expensive for an individual programmer (i.e. $600 US). I loved the fact that it was non-invasive (did not change your code), and that it could do line-by-line profiling, until I found that because it is an instrumenting profiler, it can lead to improper optimizations as in: Why is CharInSet faster than Case statement?
I tried a demo of ProDelphi, much less expensive (about $80 I think), but it was much too clunky for me - I didn't like the user interface at all, and it is invasive - changing your code to add the instrumenting, which you have to be careful about.
I used GpProfile with Delphi 4 for many years. I loved it. It also was invasive, but it worked so well I learned to trust it and it never gave me a problem in 10 years. But when I upgraded to Delphi 2009, I didn't think it best to try using it, since it hasn't been upgraded and by GP's admission, won't work without modifications. I expect you won't be able to use it either with Delphi 2006.
ProDelphi and GpProfile will only profile at the procedure level. If you want to do individual lines (which I sometimes had to), you have to call PROC1, PROC2, PROC3 for each line and put the one line in each PROC. It was a bit of an annoyance to have to do that, but it gave me good results (at least I was happy with the results of GpProfile doing that).
The answer I accepted in my CharInSet question said that "Sampling profilers, which periodically check the location of the CPU, are usually better for measuring code time." and a later answer gave Eric Grange's free sampling profiler for Delphi that now supports Delphi 2009. I haven't tried it yet, but I've heard good things about it, and it is the next one I'm going to try.
By the way, you might be best off by saving your $600 by NOT buying AQtime, and instead using that to upgrade your Delphi 2006 to Delphi 2009. The stability, speed and extra features (expecially Unicode), will be worth your while. See: What are major incentives to upgrade to D2009 (Unicode excluded)?
Also AQtime does not integrate into Delphi 2009 yet.
One other free one, with source that I found out about, but haven't tried yet is TProfiler. If anyone has tried that one, I'd like to know what they think.
Note: The Addenum I added afterwards to question 291631 seems like it may be the answer. See Andre's open source program: asmprofiler
Feb 2010 followup. I bit the bullet and purchased AQTime. A few months ago they finally integrated it into Delphi 2009 which is what I use (but they still have to do Delphi 2010). The viewing of source lines and their individual times and counts is invaluable to me, and AQTime does a superb job of this.
I have just found a very nice free sampling profiler and it supports Delphi 2009
I've used ProDelphi, mostly to determine which routines are eating the most time. It's an Instrumenting Profiler, meaning it adds a bit of code to the beginning and end of each routine. You control which routines it profiles by directives inside comments. You can also profile sections of a routine. But the sections must start and stop at the same block level, with no entry into or exit out of the section. Optimization must be off where ProDelphi inserts it's code (where you put the directives), but you can turn it on anywhere else.
The interface is kinda klunky, but very fast once you get the hang of it. You can do useful work with the free version (limited to 10 routines or sections). ProDelphi can quickly tell you which routines you should examine. But not why, or which lines.
Recently, I've started using Intel's VTune Performance Analyzer. 'WOW' doesn't begin to sum it up. I am impressed. I simply had no idea all this was built into modern Intel processors. Did you know it can tell you exactly how often a single instruction needed to wait for the L1 Data Cache to look sideways at another core before reloading a word from a higher cache? If I keep writing, I'll just sound like a breathless advert for the product.
Go to Intel and download the full-working timed demo. Dig around the net and find a couple of videos on how to get started. (Otherwise, you run the risk of being stymied by all the options.) It works with any compiler. Just point it to a .exe. It'll show you source lines if your .exe includes debug info & you point it to the source code.
I was stuck trying to optimize an inner loop that called a function I wrote. There were no external calls except length(str). This inner loop ran billions of times per run, and ate up about half the cpu time -- a perfect candidate for optimization. I tried all sorts of standard optimizations, with little to no effect. VTune shows hot-spots. I just drilled down till it showed me the ASM my code generated, and how much time each instruction took.
Here's what VTune told me:
line nnnn [line of delphi code] ...
addr hhhh cmp byte ptr [edx+ecx],0x14h - - - - - - - - 3 cycles
addr hhhh ja label_x - - - - - - - - - - - - - - - - - - -10302 cycles
The absolute values mean nothing. (I think I was measuring cycles per instruction retired.) The relative values make it kinda clear where all the time went. The great thing was the Advice Window. It told me the code stalled waiting for data to load into the L1 data cache, and actually gave me good advice on how to avoid stalls.
My mistake was in thinking of the Core2 Quad as just a really fast 8086 CPU. No^3. The code was spending 99% of its time waiting for data to load from memory because I was jumping around too much. My algorithm assumed that memory was RAM (Random Access). That's not how modern CPUs work. Data in L1 cache might be accessed in 1 or 2 cycles, but accessing the L2 or L3 cache costs tens to hundreds of cycles, and going to RAM costs thousands. However, all that latency is avoided when you access your data sequentially -- because the processor will pre-load the cache with the data following the first byte you ask for.
Net result is that I rewrote the algorithm to access the data more sequentially, and got a 10x speedup, which was good enough. When I have the time, I'm certain I can get another 10x out of it. But that's just the Geek in me. Good Enough is good enough.
I already knew that you get the most bang by optimizing your algorithm, not your code. I thought I only needed the profiler to tell me what needed optimizing. But I also needed it to find the reason for the bottleneck so I could design a faster algorithm.
The new algorithm isn't radically different from the old. It just stores the data such that it can be accessed sequentially. For example, in one place I moved a field from an array of records into it's own array of integers -- because the inner loop didn't need the rest of the data in each record. I also had a rectangular matrix stored as a dynamic array of dynamic arrays. The code used this to randomly access megabytes of data (and the poor L1 data cache is only 64Kb). I figured out how to store it in a linear array as diagonals of the matrix, which is the order I use the data. (OK, maybe that part is radical.)
Anyway, I'm sold on VTune.
I have used http://www.prodelphi.de with success on Delphi 7 project in the past. Cheap and works. Don't let the bush league web site scare you off.
www.AutomatedQA.com has the best choice for Delphi profiling (AQTime)
I use and recomend Sampling Profiler, I think you can get it from embarcadeiro.public,attachments newsgroup.
Here's another choice, I haven't used this one before: http://www.prodelphi.de
Final choice that I know of for Delphi, http://gp.17slon.com/gpprofile/index.htm
Final note, www.torry.net is a great place for Delphi component/tool search
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I was wondering; which logging libraries for Delphi do you prefer?
CodeSite
SmartInspect
Log4Delphi
TraceFormat
Please try to add a reasoning why you prefer one over the other if you've used more than one.
I'll add suggestions to this question to keep things readable.
I've used Codesite and it has been fantastic. On one project, a word-processor, I could easily output a million debug lines, all structured, and Codesite helped greatly with its auto-collapsing indented output. For any task where you have to know what really is happening "underneath" a process that can't be interrupted by user interaction, Codesite is really good. I recommend it heartily.
SmartInspect is really useful. It is the only one I have used. The logging library is good, but the console and the remote TCP/IP logging takes it over the top. I think CodeSite has some similar features.
Take a look at the features of this Open Source unit:
http://blog.synopse.info/post/2011/04/14/Enhanced-logging-in-SynCommons
logging with a set of levels (not only a hierarchy of levels);
fast, low execution overhead;
can load .map file symbols to be used in logging;
compression of .map into binary .mab (900 KB -> 70 KB);
optional inclusion of the .map/.mab into the .exe;
handle libraries (.ocx/.dll);
exception logging (Delphi or low-level exceptions) with unit names and line numbers;
optional stack trace with units and line numbers;
methods or procedure recursive tracing, with Enter and auto-Leave;
high resolution time stamps, for customer-side profiling of the application execution;
set / enumerates / TList / TPersistent / TObjectList / dynamic array JSON serialization;
per-thread, rotating or global logging;
multiple log files on the same process;
optional colored console display;
optional redirected logging (e.g. to third party library, or to a remote server);
log viewer GUI application, with per event or per thread filters, and method execution profiler;
Open Source, works from Delphi 5 up to XE6 (Win32 and Win64).
Your feedback is welcome!
And don't forget the free open source TraceTool
I have just updated Log4Delphi 0.8 on the Sourceforge page and it rolls up patches and bug fixes from the last 4 years.
Sourceforge Log4Delphi Downloads
Log4net/ports of Log4xxx to other languages. It's open-source, pretty wide-spread, popular, has a good community behind, and isused widel (for example, in Hibernate/nHibernate).
An important value behind CodeSite is Ray Kanopka's support. He personally answers emails and newsgroup posts, and has done so for many years. His answers often contain code that illustrates excellent coding habits.
I didn't use CodeSite probably because I'm completely happy with SmartInspect. Highly recommended.
I am looking into Codesite as well. I built my own in the past but I really like the featrues in Codesite. The Raize componenets are very well written and always quality stuff.
Log4D is another implementation which is based on Log4J and easy to extend and configure.