optimization

How to measure performance in a C++ (MFC) application?

What good profilers do you know? What is a good way to measure and tweak the performance of a C++ MFC application? Is Analysis of algorithms really neccesary? http://en.wikipedia.org/wiki/Algorithm_analysis ...

Optimising C++ 2-D arrays

I need a way to represent a 2-D array (a dense matrix) of doubles in C++, with absolute minimum accessing overhead. I've done some timing on various linux/unix machines and gcc versions. An STL vector of vectors, declared as: vector<vector<double> > matrix(n,vector<double>(n)); and accessed through matrix[i][j] is between 5% and 100...

What can I do to increase the performance of a Lua program?

I asked a question about Lua perfromance, and on of the responses asked: Have you studied general tips for keeping Lua performance high? i.e. know table creation and rather reuse a table than create a new one, use of 'local print=print' and such to avoid global accesses. This is a slightly different question from Lua Patterns,Tips ...

Flash rendering: optimisation tips and tricks

I'm about to push out a website soon and so I've gotten in the last stages. Time to optimize the baby! The website performs pretty good overall, with an average framerate of 32fps. But at some heavy animation parts it likes to drop a couple of frames to about 22fps. Which is not that horrible. But I'm tweaking it as much as possible to k...

AI Applications in C++: How costly are virtual functions? What are the possible optimizations?

In an AI application I am writing in C++, there is not much numerical computation there are lot of structures for which run-time polymorphism is needed very often, several polymorphic structures interact during computation In such a situation, are there any optimization techniques? While I won't care to optimize the application ...

flash: for loops running slow

I have a question about loops in flash.... In a tile game I'm making a have a mini map of the whole level. The way it renders the map is a function with a for loop in another for loop. It cycles through each tile position and attaches a map piece (basically a 3x3 pixel square) which is colored according to what the tile is. Anyway, my p...

How to optimize PostgreSQL Configuration? (Is there a tool available?)

In postgresql you have a wealth of optimizations at hand to configure it for your performance needs. The settings for memory usage are still easy enough, but with other options like the cost factors for CPU and IO which are used for the query optimizer are quite a mystery for me. I wonder if there is a program available which would do le...

Language showdown: Lazy (aka short-circuit) evaluation for And and Or applied to a list.

If I have a boolean function f(x) = {print(x); return is_even(x)} that does some time-consuming (in this example, for illustrative purposes, side-effect-producing) stuff and a list a={2,3,4} I can check if f() is true for every element of a with apply(And, map(f, a)) but that wastefully applies f to every element of a instead of retur...

.NET multiplication optimization

Does the compiler optimize out any multiplications by 1? That is, consider: int a = 1; int b = 5 * a; Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as: const int a = 1; ...

Best algorithm for synchronizing two IList in C# 2.0

Imagine the following type: public struct Account { public int Id; public double Amount; } What is the best algorithm to synchronize two IList<Account> in C# 2.0 ? (No linq) ? The first list (L1) is the reference list, the second (L2) is the one to synchronize according to the first: All accounts in L2 that are no longer pr...

Does this query look optimized?

I'm writing a query for an application that needs to list all the products with the number of times they have been purchased. I came up with this and it works, but I am not too sure how optimized it is. My SQL is really rusty due to my heavy usage of ORM's, But in this case a query is a much more elegant solution. Can you spot anything...

For your complicated algorithms, how do you measure its performance?

Let's just assume for now that you have narrowed down where the typical bottlenecks in your app are. For all you know, it might be the batch process you run to reindex your tables; it could be the SQL queries that runs over your effective-dated trees; it could be the XML marshalling of a few hundred composite objects. In other words, you...

PHP Script Compression/"Compilation" Tools

Are there any more generic tools that can "compile" or basically merge multiple PHP files into a single file based on includes and autoloading classes? I'm thinking of something similar to Doctrine's compiling functionality or the compiling that many of the major JS frameworks do for "production" sites to lighten the file size and improv...

Do Javascript properties calculate on each call?

Since length is a Javascript property, does it matter whether I use for( var i = 0; i < myArray.length; i++ ) OR var myArrayLength = myArray.length; for( var i = 0; i < myArrayLength ; i++ ) Thank you. ...

Populating a PHP array: check for index first?

If I'm deep in a nest of loops I'm wondering which of these is more efficient: if (!isset($array[$key])) $array[$key] = $val; or $array[$key] = $val; The second form is much more desirable as far as readable code goes. In reality the names are longer and the array is multidimensional. So the first form ends up looking pretty gnarly...

How do you make Flash not render an object on the Stage?

This discussion started over here but I thought it would be nice to have a definitive answer... So let's say you have MovieClip on the Stage (or a UIComponent for the Flex audience) - what do you have to do to not make it so that the user can't see the object but also so that the AVM2 doesn't even factor it in when rendering the stage f...

How to improve garbage collection performance?

What kind of optimization patterns can be used to improve the performance of the garbage collector? My reason for asking is that I do a lot of embedded software using the Compact Framework. On slow devices the garbage collection can become a problem, and I would like to reduce the times the garbage collector kicks in, and when it does,...

Close point of approch detection

I have a large set of 3rd order polynomials in 3D. in matrix form [Pn](t) = [1,t,t^2,t^4]*[An] // [Pn] and [An] are matrices each function has a weight Wn. I want to, for some n, m, T and t0 find the first t where t>t0 such that Wn*Wm / |[Pn](t)-[Pm](t)|^2 > T aside from a the O(n^2) "try everything" approach I'm not even sure w...

Apache Webserver security and optimization tips

Hi. I'm about to deal with managing and running my first Internet connected Apache webserver and I was wondering if there are any sys admins and developers out there that would like to share some of their knowledge regarding security and optimization tips for running Apache webserver. Maybe you can share your top five (or ten) list of ...

What's the fastest way to divide an integer by 3?

int x = n / 3; // <-- make this faster // for instance int a = n * 3; // <-- normal integer multiplication int b = (n << 1) + n; // <-- potentially faster multiplication ...