optimization

Two loop bodies or one (result identical)

I have long wondered what is more efficient with regards to making better use of CPU caches (which are known to benefit from locality of reference) - two loops each iterating over the same mathematical set of numbers, each with a different loop body, or having one loop that "concatenates" the two bodies into one, and thus accomplishes id...

delay the loading of 3rd party javascript

Is there ANY method to delay the loading of 3rd party JavaScript files until the rest of the page has finished loading? ...

Test and echo without repetition?

This is a minor thing, but it's been bugging me for a while. I've wracked my brain for a way to write statements like this without any repetition of code. For example: echo isset($array[0])? $array[0]: 'not set'; $var = empty($other_var)? '$other_var not set': $other_var; Is there some sort of test-and-return (for the former) or tes...

Optimizing Sqlite query for INDEX

Hello, I have a table of 320000 rows which contains lat/lon coordinate points. When a user selects a location my program gets the coordinates from the selected location and executes a query which brings all the points from the table that are near. This is done by calculating the distance between the selected point and each coordinate poi...

How do I tell how much memory / resources is my php script using up?

Hi guys I'm debugging my application here and basically in a nutshell - the application is dying out on my online server or maybe its my server dying out. But I have checked this application three different servers and all exhibited similar results, the application would run for a while but all of a sudden once I'd be opening more and mo...

(Java) Store a huge collection of objects with indexed attributes

I need to store about 100 thousands of objects representing users. Those users have a username, age, gender, city and country. The users should be searchable by a range of age and any of the other attributes, but also a combination of attributes (e.g. women between 30 and 35 from Brussels). The results should be found quickly as it is o...

How can I optimize my routine to build HTML tiles from an array?

As my last question was closed for being "too vague" - here it is again, with better wording. I have a "grid" of li's that are loaded dynamically (through JavaScript/jQuery), the Array isn't huge but seems to take forever loading. So, SO people - my question is: Am I being stupid or is this code taking longer than it should to execute?...

Creating a swatch library.

Hey all, I'm working on cleaning up my code from previous semesters. Previously I created a 151 color swatch library in c++. However because of my time crunch and lack of experience, I created it entirely as a block of define statements. Which, for hard coding values into spots worked fine. However there are some obvious weaknesses to t...

android png optimization

I have an app that using alot of .png fils, so to reduce app size I used PngOptimizer to optimze them. I was happy with the results and the file size of the png's went from alittle over 1mb to 300kb or so. but for some reason the app size only went down about about 100kb. doesn anyone know why? I would really like the file size reduc...

Help me optimize VBA Excel code for copying certain columns of every row on a sheet to another.

Hi all, I need to copy certain columns of every row in sheet A into sheet B. I have created a sub that creates 2 arrays (variants) of the matching column numbers, so I can map column 3 in sheet A to be equal to column 8 in sheet B, etc. Everything works fine, thing is it's quite slow, here it is: Sub insertIntoSelectedOpps(opCols As...

with index, returns different result.

Never seen this before. Running the same query, 1 forces an index. Without the index, the results are incorrect (in wrong order), with the index the results are in the correct order. Only problem with using the index is that its slower for some reason. Index is on comment_id and user_id without index: SELECT DISTINCT topic_id FROM comm...

quickest way to dynamically retrieve image dimensions

One way to improve page loading is to specify image dimesions (hieght width). In PHP this can be done with getimagesize(), however I can imagine this would be quite slow to execute if you have alot of images. What is the best way to dynamically get image dimensions of many images with minimal effect on page loading. We are talking about...

No duplicate rows, but redundant data

I have a mySQL table which represents a company's products. The table shows whether or not two products are compatible with each other. The table looks somewhat like Product1 Product2 Compatible? A A Yes A B ? A C No A D ? B A ? B ...

What is linear programming?

I read over the wikipedia article, but it seems to be beyond my comprehension. It says it's for optimization, but how is it different than any other method for optimizing things? An answer that introduces me to linear programming so I can begin diving into some less beginner-accessible material would be most helpful. ...

Suggestions to Increase tcp level throughput

we have an application requirement where we'll be receiving messages from around 5-10 clients at a rate of 500KB/sec and doing some internal logic then distrubuting the received messages among 30-35 other network entities. What all the tcp level or thread level optimizations are suggested ? ...

Speed up forum conversion

I'm converting a forum from myBB to IPBoard (the conversion is done through a PHP script), however I have over 4 million posts that need to be converted, and it will take about 10 hours at the current rate. I basically have unlimited RAM and CPU, what I want to know is how can I speed this process up? Is there a way I can allocate a huge...

How can I improve these 8051 arch instructions?

I'm writing to memory space a few address and I need to optimize the code. There is a better way to do the following? SETB 00h SETB 01h SETB 02h SETB 03h SETB 04h SETB 05h SETB 06h SETB 07h ...

Increment filename

I want to create algorithm, to generate name for new file which I want to add to main directory. All files in this directory must has unique name and start with "myFile" What do you think about this algorithm ? Can I optimize it ? string startFileName="myFile.jpg"; string startDirectory="c:\MyPhotosWithSubFoldersAndWithFilesInMainDirec...

32x32 Multiply and add optimization

Hi, I'm working on optimizing an application . I found that i need to optimize an inner loop for improved performance. rgiFilter is a 16 bit arrary. for (i = 0; i < iLen; i++) { iPredErr = (I32)*rgiResidue; rgiFilter = rgiFilterBuf; rgiPrevVal = rgiPrevValRdBuf + iRecent; rgiUpdate = rgiUpdateRdBuf + iRecent; iPre...

C optimization question

Hi, I'm wondering what is the fastest way that I can write some code. I have a loop which executes an add on some ints. The loop will be executed many, many times and so I've thought of making comparisons to check if any operands are zero, so they shouldn't be considered to be added, as follows: if (work1 == 0) { if (work2 == 0) ...