Re: Static vs. instance method: Which one performs better?

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Mar 1, 3:35 am, gnewsgroup <gnewsgr...@xxxxxxxxx> wrote:

<snip>

I guess the task of the methods in the code above is too light to
yield any significant result.

Definitely. Even if there *were* a difference, you'd have to call a
method millions or even *hundreds* of millions of times to see it.

So, I am wondering, in general, if
there is a performance difference between a static method and an
instance method, assuming that they do exactly the same thing.

Anyone has an idea? Thank you.

In theory a static method might be very, very, *very* slightly faster
- there's no "this" parameter to pass.

However, this should never *ever* be the deciding factor in whether or
not to make a method static.

Jon
.



Relevant Pages

  • Re: OO conventions
    ... subclass object (likely by passing a string to the constructor, e.g., ... Image.opendefined as a static method (wait...is that ...
    (comp.lang.python)
  • Re: MT and Classes: MVP & Threading Experts Only
    ... BigFish wrote: ... for threads to be started only via the static method start, ... class can only be done by member functions or your class (either static ...
    (microsoft.public.vc.language)
  • Re: Arrays
    ... >>2 define a public static method called replaceArrayElement() that takes ... >>value(aString object reference) as arguments ...
    (comp.lang.java.help)