How can a Delphi TForm / TPersistent object calculate its own construction and deserialization time?
Posted
by mjustin
on Stack Overflow
See other posts from Stack Overflow
or by mjustin
Published on 2010-03-14T12:27:57Z
Indexed on
2010/03/14
17:55 UTC
Read the original article
Hit count: 416
For performance tests I need a way to measure the time needed for a form to load its definition from the DFM. All existing forms inherit a custom form class.
To capture the current time, this base class needs overriden methods as "extension points":
- start of the deserialization process
- after the deserialization (can be implemented by overriding the
Loaded
procedure) - the moment just before the execution of the
OnFormCreate
event
So the log for TMyForm.Create(nil)
could look like:
- 00.000 instance created
- 00.010 before deserialization
- 01.823 after deserialization
- 02.340 before OnFormCreate
Which TObject (or TComponent) methods are best suited? Maybe there are other extension points in the form creation process, please feel free to make suggestions.
Background: for some of our app forms which have a very basic structure (with some PageControls and QuantumGrids) I realized that it is not database access and other stuff in OnFormShow but the construction which took most of the time (around 2 seconds) which makes me wonder where this time is spent. As a reference object I will also build a mock form which has a similar structure but no code or datamodule connections and measure its creation time.
© Stack Overflow or respective owner