473,671 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1444
In article <42************ **********@drea der2.news.tisca li.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.discl aimer>
_
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
7185
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 from the platform used. I already know that I can use curses (on linux/unix) or Tkinter. Also, I found this http://my.execpc.com/~geezer/software/kbhit.c C source that has a kbhit() and a getch() for linux/unix that I can SWIG to python.
5
14214
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 mission critical roll in our organization, so I'd like some comments on what others think of this database platform. Mainly I'm curious how easy/difficult it is to query a Cache Database, and does it use standard SQL calls like Oracle and MS SQL? ...
14
2126
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 assumption is wrong, then nevermind! :) But if it's true, what will be necessary to run these programs on a Mac, for example? I know they would need an equivalent to the .NET Framework, but does something like this exist yet, or is the "platform...
16
3914
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 Andy
16
2457
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 _mysql.so. So it is not platform-independent because for each web-server on different platform, I would have to download it and extra compile it specifically for that platform. Do you know of any Python solution for MySQL access that is 100%...
11
1756
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
2144
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 functionality being kept separate. I've been going over the various approaches I could follow in order to implement the OS-specific functionality. The requirements I have are as follows :
3
7493
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 executable is platform dependant: 2.2.2 Executable Python Scripts On BSD'ish Unix systems, Python scripts can be made directly executable, like shell scripts, by putting the line
114
3852
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 to use embedded python in a couple of our new products, given all the great things about python. We were close to using lua but for various reasons we decided to go with python. However, over the last two years, there's been one area of grief...
0
8473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8597
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.