optimization

Recursion overhead -- how serious is it?

Possible Duplicate: Is recursion ever faster than looping? I was first trained to program seriously in C, about 15 years ago. My employer wanted highly optimized code for computationally difficult tasks. I remember being advised more than once to rewrite recursions as loops, even at the expensive of readability, in order to ...

SIMD code for exponentiation

Hi all, I am using SIMD to compute fast exponentiation result. I compare the timing with non-simd code. The exponentiation is implemented using square and multiply algorithm. Ordinary(non-simd) version of code: b = 1; for (i=WPE-1; i>=0; --i){ ew = e[i]; for(j=0; j<BPW; ++j){ b = (b * b) % p; if (ew...

challenge: optimize unlisting [easy]

Because SO is a bit slow lately, I'm posting an easy question. I would appreciate it if big fishes stayed on the bench for this one and give rookies a chance to respond. Sometimes we have objects that have a ridiculous amount of large list elements (vectors). How would you "unlist" this object into a single vector. Show proof that your ...

Optimizing multiple LINQ to Entity Framework queries

Hello, I have 2 Entity Framework entity sets with many-to-many relationship (compromised of 3 DB tables). For the sake of the example let's say I have a Worker entity and a Company entity, where each worker can work at multiple companies and each company can have many workers. I want to retrieve for each worker all the companies that h...

jQuery Collection Cache

Does anyone know a good way to cache a collection of objects returned by a selector. var $platforms = $(".platforms"); var i = 0, l = $platforms.length, current; for(;i<l;i++) { current = $($platforms[i]); //calling jQuery() in a loop. Should be cached } The above code creates a jQuery instance of each element returned by $("...

JQuery optimization for searching classes

I have some filters on the left. Each filter has an id. The id of that filter is used to filter some results that have the id of the filter in their classes. Filters refer to characteristics of products.. example <a id="filter_colorRED">RED</a> ... <li id="item4" class="filter_colorBLUE">Blah Blah</li> <li id="item5" class="filter_co...

SQLite Optimization for Android application

We have about 7-8 tables in our Android application each having about 8 columns on an average. Both read and write operations are performed on the database and I am experimenting and trying to find ways to enhance the performance of the DataAccess layer. So, far I have tried the following: Use positional arguments in where clauses (R...

Optimizing interpolation in Mathematica.

As part of my work, I often have to visualize complex 3 dimensional densities. One program suite that I work with outputs the radial component of the densities as a set of 781 points on a logarithmic grid, ri = (Rmax/Rstep)^((i-1)/(pts-1), times a spherical harmonic. For low symmetry systems, the number of spherical harmonics can be fa...

Obsolete Java Optimization Tips

There are number of performance tips made obsolete by Java compiler and especially Profile-guided optimization. For example, these platform-provided optimizations can drastically (according to sources) reduces the cost of virtual function calls. VM is also capable of method inlining, loop unrolling etc. What are other performance optimi...

How can I optimize this confusingly slow query in MySQL?

I have a table of blog posts, each with a foreign key back to it's author. There are < 15,000 entries in this table. This query scans over 19,000 rows (per EXPLAIN), requires a filesort (that might be regular MySQL behavior), and takes over 400ms to return 5 rows. possibly because of the complicated WHERE used to check if the item is act...

Are If Thens faster then multiplication and assignment?

I have a quick question, suppose I have the following code and it's repeated in a simliar way 10 times for example. if blah then number = number + 2^n end if Would it be faster to evaluate: number = number + blah*2^n? Which also brings the question, can you multiply a boolean value times a integer (Although I am not sure the ty...

logging visitors online for large traffic website.

Hi, I manage a rather large traffic website. On each page we keep track of a visitors online by running the following code. We then have a cron which deletes the records which are older than X minutes. if(!isset($_SESSION[users_online_id])) { if(!(date('H')=='02' && date("i") >= 37 && date("i") <= 45)) { # NEW VISITOR - DOESN'T HAVE...

Valgrind output interpretation

Let arr be an array of dimension 16 x 20 Here is the valgrind output for the code snippet mentioned. The output is from cachegrind. for (i = 0; i < 20; i++) arr[0][i] = 0; Ir I1mr I2mr Dr D1mr D2mr Dw D1mw D2mw 64 0 0 41 0 0 1 0 0 60 0 0 20 0...

How to make orientation response faster in ipad?

Hi friends, I have ipad application which has 3 tableviews with holds data like label,image,property lists etc, as while performing orientation it has some overlapping,slow response compared to native apps, I have tried some methods like willRotateToInterfaceOrientation etc, is that any thing that make sense to make orientation faster...

Java enum in practice, bad code to improve

I want to improve my use of JDK 1.5 and stop using private static final String instead of enum. This is what seems to be recommended. But now my constant class looks like this : public class CEnum{ /** * @author JJA * date : 20/10/2010 */ public enum ListTypeAffichage { DEP("DEPOT_TVA"), PAD("PAS_DEPOT_T...

A Question about Good Practices in Android and Java Development

Good Morning (Afternoon, evening, i dunno what time it is when ur reading this .. lol but its 8:30 AM here :) ) I was yesterday in a Meetup about android programming and The presenter had a sample code about how to create an app with database access in android.. We talked about various classes, methods and so on. Lets assume we have a...

Web browser plugin for jquery performance optimization

Attempting to improve the perforance of my jquery - so step 1 for me is to optimize my selectors. I have been using jsperf.com which has been helpful but is there any web browser plugin that I can use that will do similar as jsperf? ie. I can enter several different selectors and it tell me which is the slowest etc or the timing each sel...

How to optimize this query using better date comparsion in SQL?

Hello, I have problem with this query, complexity of this query is not good, i use this query from long time and now this database have many rows to get selecting by this method. All index'es is added propertly. I searching some other method to optimize this query by date comparsion because this is bottleneck in this solution. SELECT (...

How to optimize this line of C code (checking range)?

Is there any way to optimize the following line of C code (to avoid branching)? if ((i < -threshold) || (i > threshold)) { counter++; } All variables are 16-bit signed integers. An optimized version should be highly portable. ...

Javascript: dictionary membership check speed

I was curious as of what would be the fastest way to check if a JS object (used as a dictionary) has a given property. And I was baffled by the results. See for yourself: http://jsperf.com/object-membership-check-speed/6 In Chrome, the in keyword method is 96% slower than the dot syntax. And in Firefox, it's also around 80% slower. IE ...