Board index » delphi » How to make my program lean and mean ? - any tips out there !

How to make my program lean and mean ? - any tips out there !

I need to optimise my program for maximum efficiency  ( if there is such
a thing )  in terms of load time, execution speed and resource usage.
What can I do to the program/delphi environment to achieve this. Your
tips  appreciated. TIA Sam
 

Re:How to make my program lean and mean ? - any tips out there !


Make sure all forms but you main form are NOT Autocreated by Delphi.
What seems to be slow is the opening of datafiles in the BDE.
I have found no fix for that.
Also, make sure filters aren't going on when they don't have
to.. for example, don't filter data on a grid that is invisible.

I hope other people have good ideas to post.

Quote
Sam <Sam-NoS...@Compuserve.com> wrote in message

news:378B5E00.F093B5A6@Compuserve.com...
Quote
> I need to optimise my program for maximum efficiency  ( if there is such
> a thing )  in terms of load time, execution speed and resource usage.
> What can I do to the program/delphi environment to achieve this. Your
> tips  appreciated. TIA Sam

Re:How to make my program lean and mean ? - any tips out there !


On Tue, 13 Jul 1999 16:40:48 +0100, Sam <Sam-NoS...@Compuserve.com>
wrote:

Quote
>I need to optimise my program for maximum efficiency  ( if there is such
>a thing )  in terms of load time, execution speed and resource usage.
>What can I do to the program/delphi environment to achieve this. Your
>tips  appreciated. TIA Sam

You can implement some optimisation by using the project options -
only have checked in the retail build what you really need.

You can track down bottlenecks using profiling tools (I have found
GpProfile useful).

If you only need certain resources for relatively short periods of
time you can create and free them in code at the latest/earliest
opportunity.

If you make use of DLLs you should investigate the possibility of
loading them from code at the point they are required.

Investigate the use of runtime packages, particularly if you have
several Delphi apps as part of a suite.

On the whole I would say that writing code that can be easily read and
maintained is an excellent optimisation. The Delphi compiler doesn't
do a bad job of producing efficient code, and if you get too clever in
your coding techniques you may very well prevent the compiler from
doing it's magic.

You didn't really say much about what you are trying to achieve,
perhaps if you supply a bit more detail others may have specific tips.

HTH

--
Gary Wilmot
Senior Developer
Vizual Business Tools Ltd
http://www.vizual.co.uk

Re:How to make my program lean and mean ? - any tips out there !


On Tue, 13 Jul 1999 11:46:19 -0400, "Art Begun"

Quote
<beg...@mindspring.com> wrote:
>Make sure all forms but you main form are NOT Autocreated by Delphi.

yeah, I forgot that one :-(

Quote
>What seems to be slow is the opening of datafiles in the BDE.
>I have found no fix for that.

You may find _some_ benefit in having a small app run as part of the
startup process - it will ensure the necessary DLLs are loaded. This
can work for apps using runtime packages too.

Quote
>I hope other people have good ideas to post.

No doubt they will, I rather thought you did a good job anyway Art :-)

--
Gary Wilmot
Senior Developer
Vizual Business Tools Ltd
http://www.vizual.co.uk

Re:How to make my program lean and mean ? - any tips out there !


Quote
>>You can track down bottlenecks using profiling tools (I have found

GpProfile useful).

Thanks for response. Where to get this profiler ?

Quote
>>You didn't really say much about what you are trying to achieve,perhaps if

you supply a bit more detail others may have specific tips.

What triggered this was a note from my customer saying that his program was
taking too long to load and move from screen to screen. I then thought that
it might be a number of things but did not know where to start. So hopefully
some general points will lead me closer to what I and many others who program
want. 'Fast and robust programs' that make best use of the language in which
they were designed.

Re:How to make my program lean and mean ? - any tips out there !


I know it is hard to get a customer to spend
money but RAM speeds up Windows dramtically and
also decreases movement of the heads on the hard drive.
That should decrease wear and tear on the mechanism
so the ram might pay for itself if the hard drive lasts longer.
(Yes, I know its a stretch...  but I can hope can't I.)
I went from 64 megs to 256 megs on a Compaq with
a notoriously slow hard drive.  The speed increase
was dramatic.

You can also look into subforming if you have a screen
with many pages of tabsheets.  That way the pages are
created on the fly instead of when the form is created.
It was important trick in D1 and documented in many D1 books.

Quote
Sam <Sam-NoS...@Compuserve.com> wrote in message

news:378B659C.A4B9A57C@Compuserve.com...
Quote
> >>You can track down bottlenecks using profiling tools (I have found
> GpProfile useful).

> Thanks for response. Where to get this profiler ?

> >>You didn't really say much about what you are trying to achieve,perhaps
if
> you supply a bit more detail others may have specific tips.

> What triggered this was a note from my customer saying that his program
was
> taking too long to load and move from screen to screen. I then thought
that
> it might be a number of things but did not know where to start. So
hopefully
> some general points will lead me closer to what I and many others who
program
> want. 'Fast and robust programs' that make best use of the language in
which
> they were designed.

Re:How to make my program lean and mean ? - any tips out there !


On Tue, 13 Jul 1999 17:13:16 +0100, Sam <Sam-NoS...@Compuserve.com>
wrote:

Quote
>>>You can track down bottlenecks using profiling tools (I have found
>GpProfile useful).

>Thanks for response. Where to get this profiler ?

http://www.eccentrica.org/gabr/gpprofile/files.htm

--
Gary Wilmot
Senior Developer
Vizual Business Tools Ltd
http://www.vizual.co.uk

Re:How to make my program lean and mean ? - any tips out there !


On Tue, 13 Jul 1999 17:13:16 +0100, Sam <Sam-NoS...@Compuserve.com>
wrote:

Quote
>>>You can track down bottlenecks using profiling tools (I have found
>GpProfile useful).

>Thanks for response. Where to get this profiler ?

>>>You didn't really say much about what you are trying to achieve,perhaps if
>you supply a bit more detail others may have specific tips.

>What triggered this was a note from my customer saying that his program was
>taking too long to load and move from screen to screen. I then thought that
>it might be a number of things but did not know where to start. So hopefully
>some general points will lead me closer to what I and many others who program
>want. 'Fast and robust programs' that make best use of the language in which
>they were designed.

I assume this is a database app? Did you mention which version of
Delphi? Which version of the BDE? Also you may need to investigate the
BDE configuration, there are articles on the borland web pages
relating to BDE configuration - I am _sure_ some kind soul in TeamB
will be posting such urls for you...

--
Gary Wilmot
Senior Developer
Vizual Business Tools Ltd
http://www.vizual.co.uk

Re:How to make my program lean and mean ? - any tips out there !


For behind the scenes data manipulation: DisableControls/EnableControls.
Use MemoryTables for lookups.  You've already been told about creating
forms/data modules when needed.

Use a profiling tool to test major routines for execution speed.

But, if speed is the most important consideration - tell your clients to get
a PII and load it with memory. That's a lot cheaper than your programming
time would be.

One major point though:  It is far easier to optimize clean code, than it is
to get optimized code working.  I'm working on an accounting package now
where I'm concentrating on easily maintainable code rather than efficient
code, and you don't see the resources dip when it's running.

Quote
Sam <Sam-NoS...@Compuserve.com> wrote in message

news:378B5E00.F093B5A6@Compuserve.com...
Quote
> I need to optimise my program for maximum efficiency  ( if there is such
> a thing )  in terms of load time, execution speed and resource usage.
> What can I do to the program/delphi environment to achieve this. Your
> tips  appreciated. TIA Sam

Re:How to make my program lean and mean ? - any tips out there !


Ah, now we have ground to work with!  Had the same problem the other day.
Was taking five plus seconds to generate a new order on a Pentium II.  Got
it down to - measured by CodeSite .179 seconds.  Here's some ideas:

TQueries:    Don't use *, specify your fields, especially on a join.
Prepare the queries at the start.  Disable controls on them before you run
the query and reenable only if needed when it's done.  If you can, set them
to unidirectional - shaves a few seconds.

All datasets:  use persistant fields - gains a few milliseconds each in
access time.

Use a profiler or a debug aid like CodeSite (www.raize.com) to test each
procedure for execution time - that will point you to the major problems.
Don't use the DBNavigator - found it took (literally) ten times longer to
move to the next record than calling Next did.  Same with all other
navigations using the Navigator.

Perception is a big deal too.  Try putting a few Application.ProcessMessages
into the create routine and move some of the code into show.  That way, your
form starts drawing sooner.  Did that on my program in front of the client
and they swore it ran twice as fast - even though the time to execute was
the same.

Best of luck, and I hope this helps!

--
John Elrick
j...@improgrammer.com
www.improgrammer.com

Delphi Application/Component Development
Delphi Mentoring

Quote
Sam <Sam-NoS...@Compuserve.com> wrote in message

news:378B659C.A4B9A57C@Compuserve.com...
Quote
> >>You can track down bottlenecks using profiling tools (I have found
> GpProfile useful).

> Thanks for response. Where to get this profiler ?

> >>You didn't really say much about what you are trying to achieve,perhaps
if
> you supply a bit more detail others may have specific tips.

> What triggered this was a note from my customer saying that his program
was
> taking too long to load and move from screen to screen. I then thought
that
> it might be a number of things but did not know where to start. So
hopefully
> some general points will lead me closer to what I and many others who
program
> want. 'Fast and robust programs' that make best use of the language in
which
> they were designed.

Re:How to make my program lean and mean ? - any tips out there !


Thanks to all that replied. I will have a go at some of these ? Why does'nt
Inprise publish these  tips in their manuals so all programmers can benefit
?
Quote
Sam wrote:
> I need to optimise my program for maximum efficiency  ( if there is such
> a thing )  in terms of load time, execution speed and resource usage.
> What can I do to the program/delphi environment to achieve this. Your
> tips  appreciated. TIA Sam

Other Threads