optimization

Can a C++ compiler optimize away code when dealing with pointers?

Hello, With these two questions as background (first and second), I got curious about how much optimization a C++ compiler can perform when dealing with pointers? More specifically, I'm interested in how smart a compiler is when it optimizes away code which it may detect will never be run. (Some may point out that this is a dupe of thi...

Minimizing Sum of Distances: Optimization Problem

The actual question goes like this: McDonald's is planning to open a number of joints (say n) along a straight highway. These joints require warehouses to store their food. A warehouse can store food for any number of joints, but has to be located at one of the joints only. McD has a limited number of warehouses (say k) available, and w...

When can optimizations done by the compiler destroy my C++ code?

Hello, When can optimizations done by the compiler cause my C++ code to exhibit wrong behaviour which would not be present had those optimizations not been performed? For example, not using volatile in certain circumstances can cause the program to behave incorrectly (e.g. not re-reading the value of a variable from memory and instead o...

BIG header: one jpg or several png?

I've read some of posts here about png/jpg/gif but still I'm quite confused.. I've got a big header on my website : width:850px height:380px weight:108kb And it's jpg. A woman + gradient + some layers on top and behing her.. Do you think 108kb it's too much? I was thinking about cut it to png pieces..Would that be a bad idea? What's y...

Is there a way to optimize the way I generate a file and output it as .zip in a java servlet?

A user has a few Lookup selections on a JSP page. After he's selected what data he wants exported, the JSP calls my servlet which should do something like this: get request data generate SQL for the request data execute the SQL and write it to a XML file package the XML file to a ZIP file and return it as a response Now, the first tw...

MySQL query optimisation help

Hi guys, hoping you can help me on the right track to start optimising my queries. I've never thought too much about optimisation before, but I have a few queries similar to the one below and want to start concentrating on improving their efficiency. An example of a query which I badly need to optimise is as follows: SELECT COUNT(*) AS ...

SQLAlchemy: writing to database after the response has been sent

I have a simple service that does approximately the following: An HTTP client connects to the server The server writes the sessionID of the client and the timestamp to the database, and in most cases just returns an empty response (The cases when it does do real work and return actual data are irrelevant to this question) In order t...

Check every value in a list in TI-Basic

I'm writing a snake game in TI-Basic, and every time I move I need to see if the head of the snake has hit any point in the tail. The tail is stored as a circular list-based queue, and I can add the beginning and end in constant time. The only hard part is that I have to do something similar to this on every iteration: (S = Size of the ...

Flex w/ AMF Returning results slowly.

I think this is just a matter of fine tuning some different elements, but I'd like to know your take. I've got a Flex app, using the Flex 4 data services, communicating with Zend AMF services. One of the services returns all the results in a database using SELECT * FROM table there are ~1200 rows (140KB package size). My problem is the ...

Rails: Getting an array of object ids by query/conversion (for comparision)

Basically, I want an array of ids from the database. Some background: I'm rendering a list of objets (foos) to the user with a checkbox. If the user checks the box a row is create in a different table (bar) when rendering the foo list + checkbox I want to check if the unique id any given foo already exists in the bar id array. I ...

How to optimize this computation

Hello, I'm writing a model-checker which relies on the computation of a coefficient which is used intensively by the algorithms which is the following: where q is double, t a double too and k an int. e stands for exponential function. This coefficient is used in steps in which q and t don't change while k always starts from 0 until th...

Draw calls take WAY longer when targeting an offscreen renderbuffer (iPhone GL ES)

I'm using OpenGL ES 1.1 to render a large view in an iPhone app. I have a "screenshot"/"save" function, which basically creates a new GL context offscreen, and then takes exactly the same geometry and renders it to the offscreen context. This produces the expected result. Yet for reasons I don't understand, the amount of time (measured ...

Managing strongly typed .resx resources

Hi everyone, I added .resx files to my project and everything works ok. I can access my .resx files in the code by typing ApplicationName.resourcename which is quite nice, instead of calling resourceManager.getString(blabla). However I would like to have a structure, to access resources like: ApplicationName.Resources.Buttons.btnreso...

Of which things should I take care if I'm using unboxed type (like Int#) in Haskell / GHC?

I'm trying to write a small script which parses and executes Brainfuck code, to understand the GHC options of optimization, I'm trying to optimize the code in order to be a bit faster and to understand what's going on there. On of the parts is the internal represantation of BF-code, I use a special datatype for this. Here's the sourceco...

Optimize Oracle SQL with large 'IN' clause

Here I have a query like below: SELECT field FROM table WHERE value IN ('val1', 'val2', 'val3', ... 'valn') Let's say there are 2000 values inside the IN clause, the value doesn't exist in other table. Do you have any idea to speed up this operation? The question is open to accept any kind of methods.. Thanks! ...

What's the faster glUniform4f/glUniform4fv with consideration all kind of optimization?

Here are signatures. glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); glUniform4fv(GLint location, GLsizei count, const GLfloat *v); In my humble opinion, former should be faster because values can be passed directly from registers without fetching from memory. However, I want to hear many opinions. ...

SQL query alternative/optimization for LEFT OUTER JOIN

I have the following query: SELECT `pokemon_moves`.`pokemon_move_method_id`, `pokemon_moves`.`level`, `move`.`id`, `move`.`name` FROM `pokemon_moves` LEFT OUTER JOIN `moves` `move` ON `move`.`id` = `pokemon_moves`.`move_id` WHERE `pokemon_moves`.`pokemon_move_method_id` < '4' AND `pokemon_moves`.`...

Best C++ compiler and options for windows build, regarding application speed?

I am making a game for windows, mac and GNU, I can built it on windows already with MSVC and MingW... But I am not finding good information regarding how much compilers optmize. So what compiler, and options on that compiler, I can use to make my Windows version blazing fast? Currently the profilers are showing some worring results l...

How do I learn enough about CLR to make educated guesses about performance problems?

Yes, I am using a profiler (ANTS). But at the micro-level it cannot tell you how to fix your problem. And I'm at a microoptimization stage right now. For example, I was profiling this: for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { packedCells.Add(Data[x, y].HasCar); packedCells.Add(Data[x, ...

How to maintain a persistant connection to an email server on a webapplication..

I'm not sure if this is possible but here we go. I'm building an email module for my application. Basically it refers to an inbox on a mail server, it retrieves all headers of the emails and the details periodically. The thing I've noticed is that the connection to email itself takes a while i.e 3-5 seconds of waiting time and a connect...