Struct / Class Performance?
From: Bryan Parkoff (bryan.nospam.parkoff_at_nospam.com)
Date: 05/25/04
- Next message: CHK: "LEA instruction"
- Previous message: Phil Carmody: "Re: LDS instruction?"
- Next in thread: Robert Wessel: "Re: Struct / Class Performance?"
- Reply: Robert Wessel: "Re: Struct / Class Performance?"
- Reply: Phil Carmody: "Re: Struct / Class Performance?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 24 May 2004 22:09:29 +0000 (UTC)
I have gathered time data for global variables, struct, and class. I
have shown the result that struct is faster than global variable. Second,
struct and class have the same speed while class is not bound to these
functions. Third, class is faster than struct while class is bound to these
functions.
It is good, but inheritance is a big issue that it should be avoided.
If base class and derived class are bound through virtual or nonvirtual
inheritance, derived class must obtain a pointer from base class before it
can access variable and functions. It creates extra instructions per
variable and/or functions. It can be slow. If base class is only useful
while virtual / nonvirtual inheritance is disabled or removed, it creates
only less than two instructions per variable and/or functions. It can be
running much faster.
I was done to read C++ source and disassembler code to compare. I did
find out that base class does not need extra instructions that it can save
hundred clock cycles. It would be best to create two or more base classes.
Copy variables from first base class to second base class without using
inheritance during the initialization before each base class can process
their own variables and/or functions that can be much faster.
Do you agree? What about you (Matt Taylor)?
I do see that data flat can be huge than stack flat that will be better
since stack flat should always be smaller that it is useful to push and pop
temporal variables only. All constant and nonconstant variables are always
modified in data flat inside struct or class. Is it true?
-- Bryan Parkoff
- Next message: CHK: "LEA instruction"
- Previous message: Phil Carmody: "Re: LDS instruction?"
- Next in thread: Robert Wessel: "Re: Struct / Class Performance?"
- Reply: Robert Wessel: "Re: Struct / Class Performance?"
- Reply: Phil Carmody: "Re: Struct / Class Performance?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|