473,412 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

platform independent table access performance

Dear people,

I have a scaled up short sin(short) function which uses
a lookup table. The code will be used on different
platforms (from mobile phone to desktop computer).
(Yes, I know sizeof short can differ.)

Here my slightly OT question: Is there anything to
say about execution speed differences between using
an initialised static const short array, or an array
which I fill during start-up?

Thanks,

Kees

Nov 14 '05 #1
2 1428
In article <42**********************@dreader2.news.tiscali.nl >,
Case - <no@no.no> wrote:
Dear people,

I have a scaled up short sin(short) function which uses
a lookup table. The code will be used on different
platforms (from mobile phone to desktop computer).
(Yes, I know sizeof short can differ.)

Here my slightly OT question: Is there anything to
say about execution speed differences between using
an initialised static const short array, or an array
which I fill during start-up?


There is: "It depends".

On a desktop computer, the startup cost to compute the lookup table is
likely to not be noticeably different than the time it would take to read
in a precomputed table from wherever it's stored, and once the values are
there looking them up is almost definitely going to be done the same way
(and therefore at the same speed).

On smaller platforms, the implementation may be able to put one of them
somewhere where it can get at it faster than the other. Whether this
is the case, and which one is faster, will depend on the platform.

But, most likely, the standard rules for optimization apply here:
(1) Don't do it
(2) (for experts only) Don't do it yet

On a slow processor, you're probably looking at the difference between
"fast" and "fast"; on a fast processor, you're almost definitely looking
at the difference between "incredibly fast" and "incredibly fast".
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca
My original comment was designed to prevent this discussion arising.
I should have known better.
--CBFalconer in comp.lang.c
Nov 14 '05 #2
Further, if you're talking about an embedded environment, the pre-filled
table might be in ROM, while the run-time-calculated version will be in
RAM. Which is faster to access on the specific platform? Probably the
RAM. Will you be spending enough time in the sin() routine to justify the
initialization time?

And if you declare the array as non-const, then it will be in RAM, even if
it's pre-initialized (unless your compiler is beyond smart and getting
close to omniscient).

--
#include <standard.disclaimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hans Georg Krauthaeuser | last post by:
Hey all, this is probably a FAQ, but I didn't found the answer... I use msvcrt.kbhit() to check for a user keyboard event on windows. But now, I would prefer to make the module independent...
5
by: Alex | last post by:
Hi all, We're looking at a vendor who uses the InterSystems Cache Database Platform, but our IT department has zero experience with this system. This software package will have a pivotal and...
14
by: John Salerno | last post by:
Bear with me, but I've been reading a lot about how the .NET languages are platform independent, and I assume this means a program written in C# can be run on a Unix or Mac machine. If this...
16
by: Andy | last post by:
Hi, I have read that 'C' is platform-independent and portable. I can'tsee much a difference between the two terms. Could anyone differentiate the two? Also is the statement actually true? Thanks...
16
by: bobrik | last post by:
Hello, I am using the Python DB API for access to MySQL. But it is not platform-independent - I need a module not included in Python by default - python-mysql, and it uses a compiled binary...
11
by: Carnage | last post by:
I want to provide a common platform agnostic function declaration which references different implementations for different hardware platforms. What is the most type safe way to do this in 'C'?
6
by: greek_bill | last post by:
Hi, I'm interested in developing an application that needs to run on more than one operating system. Naturally, a lot of the code will be shared between the various OSs, with OS specific...
3
by: saneman | last post by:
I have read that Python is a platform independent language. But on this page: http://docs.python.org/tut/node4.html#SECTION004220000000000000000 it seems that making a python script...
114
by: Andy | last post by:
Dear Python dev community, I'm CTO at a small software company that makes music visualization software (you can check us out at www.soundspectrum.com). About two years ago we went with decision...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.