Re: efficiency question - nested function cals
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 02/22/04
- Next message: Daniel O'Connell [C# MVP]: "Re: C# iterators and suspend/resume in Simula 67"
- Previous message: Sami Vaaraniemi: "Re: Send large block of data failed"
- In reply to: Marc Pelletier: "Re: efficiency question - nested function cals"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 22 Feb 2004 07:46:01 -0000
Marc Pelletier <no.email@please.com> wrote:
> You are right. On 10,000 iterations the execution time is virtually the
> same.
>
> But I disagree with your other assertion, that I shouldn't worry about
> those issues until I find a bottleneck. I am just learning csharp and this
> is surely the time to establish good practices in this language. Good
> coding style, once established, can carry you far. For example the
> execution time in this case is the same, but the unnested version is much
> easier to debug.
So write that more readable code, as I suggested. If one version is
"much easier to debug", use that version until you find some *really
good* reason not to. It would be silly (IMO) to write less readable
code *everywhere* just because there's a very small chance that the
bottleneck in your code is due to one micro-optimisation. It's far more
likely to end up being either something you can't easily control
(bandwidth, another server, etc), an algorithm, or some combination of
the two (one particular way of doing something which eats bandwidth
when there's an alternative available). I can't remember the last time
a micro-optimisation like this was a problem.
(There's a big difference between this and the similar-looking decision
to use a StringBuilder when building up long strings. That's not a
micro-optimisation of syntax which you can reasonably hope the JIT can
compile away; it's a fundamental problem of creating too many objects.
Even that decision is only relevant when you know the number of strings
to append could end up being reasonably large (or more).)
It's important to get *architecture* right early on - that can make a
*huge* difference to performance, and is very hard to fix later on, but
not actual code.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Daniel O'Connell [C# MVP]: "Re: C# iterators and suspend/resume in Simula 67"
- Previous message: Sami Vaaraniemi: "Re: Send large block of data failed"
- In reply to: Marc Pelletier: "Re: efficiency question - nested function cals"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|