optimization

Optimization for division on "extern const int"

Hi, I work in project in which I have the following code: file1.c extern const int z; int x; do_some_stuff_to_calculate_x(); y = x / z; do_some_stuff_with_y(); file2.c const int z = Z_INIT_VALUE; // some value defined in some .h file. The point of interest is the division in file1.c . Since z is extern, so it is not known in comp...

PHP Loop Performance Optimization

I am writing a PHP function that will need to loop over an array of pointers and for each item, pull in that data (be it from a MySQL database or flat file). Would anyone have any ideas of optimizing this as there could potentially be thousands and thousands of iterations? My first idea was to have a static array of cached data that I w...

C++ cache aware programming

Hi! is there a way in C++ to determine the CPU's cache size? i have an algorithm that processes a lot of data and i'd like to break this data down into chunks such that they fit into the cache. Is this possible? Can you give me any other hints on programming with cache-size in mind (especially in regard to multithreaded/multicore data p...

Tuning MySQL for speedy column/index creation during development

Assume a MySQL MyISAM table with one gigabyte of data and one gigabyte of indexes. Furthermore, assume that during development columns and indexes will be added and removed from/to the table quite frequently. Due to the size of the database the column/index creation is slow when using the standard non-tuned MySQL settings. Which MySQL ...

SQL Server 2000 Delete Top (1000)

I have a large SQL Server database with a table at about 45 million records. I am archiving this table, and need to remove all entries greater than two years ago. I have the inserting into my archive table working fine, but I'm having issues with efficiency when deleting. My problem lies within the indexes currently on the table. I wou...

Optimizing image load times. (thinking differently)

I've created an interactive image thing...but it takes a little too long to load. The interactive image thing is located at: southernwindowdesign.com It uses 5 images to step through each state (by clicking and dragging). I want to keep the images high-quality; so, any further jpeg compression is out (including punypng and smush.it)....

Setting Far Future Expires Header In Code - ASP.NET

Is there a way that I can programmatically set an Expires Header in code with ASP.NET? Specifically I need to set it on an entire folder and all sub-folders, and the folder contains only static files (JavaSciprt, CSS, Images etc.) and not aspx files, so I can't just add some code to an aspx code-behind page_load. I can normally set this...

Optimize color manipulation on XNA

I am profiling my simple 2D XNA game. I found that 4% of entire running time is taken by simple operarion of adding together two Colors , one of them multiplied first by float. I need to call this method rogulthy 2000 times per frame (for each tile on map), which gave me 120000 times per second for XNA's 60 fps. Even minimal boosting of...

C vs C++ code optimization for simple array creation and i/o

I've been trying to convince a friend of mine to avoid using dynamically allocated arrays and start moving over to the STL vectors. I sent him some sample code to show a couple things that could be done with STL and functors/generators: #include <iostream> #include <vector> #include <algorithm> #include <iterator> #define EVENTS 100000...

remove numbers from a list without changing total sum

I have a list of numbers (example: [-1, 1, -4, 5]) and I have to remove numbers from the list without changing the total sum of the list. I want to remove the numbers with biggest absolute value possible, without changing the total, in the example removing [-1, -4, 5] will leave [1] so the sum doesn't change. I wrote the naive approach,...

Is it normal that my Grails application is using more than 200 MB memory at startup?

My Grails application is running in a development environment. I still didn't go into production, but in any case, is it normal that my Grails application is requiring 230 MB at startup only (with an empty bootstrap and no request handled so far)? Do you know why this is the case, how to improve memory usage in development mode and, mos...

struct size optimization

I have a structure I would like to optimize the footprint of. typedef struct dbentry_s { struct dbentry_s* t_next; struct dbentry_s* a_next; char *t; char *a; unsigned char feild_m; unsigned char feild_s; unsigned char feild_other; } dbentry; As I understand it, the compiler creates structures in memory as you de...

Performance of memory operations on iPhone

Here's the code that I use to create a differently ordered array: const unsigned int height = 1536; const unsigned int width = 2048; uint32_t* buffer1 = (uint32_t*)malloc(width * height * BPP); uint32_t* buffer2 = (uint32_t*)malloc(width * height * BPP); int i = 0; for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) ...

JavaScript: What is the performance gain by optimizing Name Lookups?

The company I work at bought us (or rather me) the jQuery Cookbook by O'Reilly which I am reading from front to back. Now I am at 5.13 which talks about Name Lookups. It claims that given the right circumstances, code which is optimized regarding Name Lookups can have an up to 70% performance boost. In one very situational example, it cl...

When should I omit the frame pointer?

Is there any substantial optimization when omitting the frame pointer? If I have understood correctly by reading this page, -fomit-frame-pointer is used when we want to avoid saving, setting up and restoring frame pointers. Is this done only for each function call and if so, is it really worth to avoid a few instructions for every funct...

Processing byte pixels with SSE/SSE2 intrinsics in C

I am programming, for cross-platform C, a library to do various things to webcam images. All operations are per-pixel and highly parallelizable - for example applying bit masks, multiplying color values by constants, etc. Therefore I think I can gain performance by using SSE/SSE2 intrinsics. However, I am having a data format problem....

What is the fastest way to test if a double number is integer (in modern intel X86 processors)

Our server application does a lot of integer tests in a hot code path, currently we use the following function: inline int IsInteger(double n) { return n-floor(n) < 1e-8 } This function is very hot in our workload, so I want it to be as fast as possible. I also want to eliminate the "floor" library call if I can. Any suggestions? ...

Tools for optimizing CSS rules by rewriting DOM paths/selectors

Do you know any tool that takes a CSS stylesheet and a bunch of HTML files and then is able to identify CSS rules on the DOM and rewrite them according to the optimal element DOM path? Example HTML snippet: <div id="container"> <div class="profile"> <img class="thumb" src="xxx" /> <span class="nickname">knoopx</span> </div> </div...

Combine many MySQL queries with logic into data file.

Background: I am parsing a 330 meg xml file into a DB (netflix catalog) using PHP script from the console. I can successfully add about 1,500 titles every 3 seconds until i addd the logic to add actors, genre and formats. These are separate tables linked by an associative table. right now I have to run many, many queries for each titl...

Sql query optimization

I have a query that I want to execute that fastest possible. Here it is: select d.InvoiceDetailId,a.Fee,a.FeeTax from InvoiceDetail d LEFT JOIN InvoiceDetail a on a.AdjustDetailId = d.InvoiceDetailId I put an ascending index on AdjustDetailId column I then ran the query with 'Show Actual Execution Plan' and the result estimated subt...