Groups | Search | Server Info | Login | Register
Groups > comp.lang.c.moderated > #380
| From | David Brown <david@westcontrol.removethisbit.com> |
|---|---|
| Newsgroups | comp.lang.c.moderated |
| Subject | Re: which one is faster? |
| Date | 2012-04-23 08:33 -0500 |
| Organization | Usenet Fact Police |
| Message-ID | <clcm-20120423-0010@plethora.net> (permalink) |
| References | <clcm-20120404-0002@plethora.net> |
On 05/04/2012 01:05, echo ma wrote:
> on a 32bit system.
>
> #pragma pack(4)
> struct TestStruct
> {
> unsigned short a;
> unsigned short b;
> unsigned int c;
> };
> #pragma pack()
> struct TestStruct t;
> t.a = 0; //step 1
> t.b = 1; //step 2
> t.c = 2; //step 3
>
> Questing is : Are these 3 steps having the same perfomance time?
>
Taken out of context, it is impossible to say. The speed of code
depends on a huge number of factors, including the compiler, compiler
options, processor (there are several dozens of commonly used 32-bit
processor architectures), cache, memory, etc., as well as the
surrounding code.
As a wild generalisation, the timing will be much the same if the
processor uses absolute addressing modes, but for processors that make
more use of pointers there will be some initial code to set up the
pointer before the first access, then each access will be quickly done.
> Sorry for my poor english.
There is no problem with your English - the problem lies in not knowing
what you are trying to ask. It is seldom a good plan to take statements
out of context and ask if that one statement is fast or slow - you have
to look at the bigger picture.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Back to comp.lang.c.moderated | Previous | Next — Previous in thread | Next in thread | Find similar
which one is faster? echo ma <fatmck@gmail.com> - 2012-04-04 18:05 -0500
Re: which one is faster? James Kuyper <jameskuyper@verizon.net> - 2012-04-23 08:31 -0500
Re: which one is faster? "Joel C. Salomon" <joelcsalomon@gmail.com> - 2012-04-23 08:33 -0500
Re: which one is faster? David Brown <david@westcontrol.removethisbit.com> - 2012-04-23 08:33 -0500
Re: which one is faster? Thomas Richter <thor@math.tu-berlin.de> - 2012-04-23 08:31 -0500
Re: which one is faster? Keith Thompson <kst-u@mib.org> - 2012-04-30 21:57 -0500
Re: which one is faster? Barry Schwarz <schwarzb@dqel.com> - 2012-04-23 08:32 -0500
Re: which one is faster? Keith Thompson <kst-u@mib.org> - 2012-04-23 08:32 -0500
Re: which one is faster? George Neuner <gneuner2@comcast.net> - 2012-04-30 21:58 -0500
csiph-web