Re: passing class to a function in c++ - performance question
From: lilburne (lilburne_at_godzilla.net)
Date: 03/30/05
- Next message: Bob Jenkins: "For what reasons?"
- Previous message: Bob Jenkins: "Mac.........!!!"
- In reply to: Profil1: "passing class to a function in c++ - performance question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Mar 2005 13:19:47 +0100
Profil1 wrote:
> Hi,
> I'm writing a code that has to be as efficient as possible both in terms of
> memory use and execution speed. I'll have to pass a class instance (which is
> an 'intelligent' array) to a function (multiple times). Taking this into
> consideration, should I pass it as a pointer or reference? Is there any book
> or site that teaches stuff like this (optimizing code for performance)?
> thanks for any help
>
>
If you want to improve performance first profile your code to determine
where the time is spent. If as a result the function which is being
called is really shown to be the bottleneck contrive to call the
function fewer times. I.e., find an algorithm that is O(log n) rather
than O(n^2). Then look to improving the way that the function does its
work for example remove sqrt(), etc.
- Next message: Bob Jenkins: "For what reasons?"
- Previous message: Bob Jenkins: "Mac.........!!!"
- In reply to: Profil1: "passing class to a function in c++ - performance question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]