optimization

Algorithm to get the excel-like column name of a number

I'm working on a script that generate some Excel documents and I need to convert a number into its column name equivalent. For example: 1 => A 2 => B 27 => AA 28 => AB 14558 => UMX I have already written an algorithm to do so, but I'd like to know whether are simpler or faster ways to do it: function numberToColumnName($number){ ...

Jquery: How to process a div after you have appended or set data to it optimally

I think this question is better served with an example. I have the following code: $.get('path/'+id,function(data){ $('#mydiv').html(data); $('.editable').button().click(function(){ //process here }); }); And it works just...

Should I denormalize properties to reduce the number of indexes required by App Engine?

One of my queries can take a lot of different filters and sort orders depending on user input. This generates a huge index.yaml file of 50+ indexes. I'm thinking of denormalizing many of my boolean and multi-choice (string) properties into a single string list property. This way, I will reduce the number of query combinations because mo...

Google App Engine index costs

From what I've understood, App Engine indexes are costly both in terms of increased overall storage size and by slowing down your writes. But do indexes only cost when they're actually used in queries and are explicitly defined in index.yaml? Or do properties such as StringProperty cost more than their non-indexed counterpart (e.g. Text...

How do I measure variability of a benchmark comprised of many sub-benchmarks?

(Not strictly programming, but a question that programmers need answered.) I have a benchmark, X, which is made up of a lot of sub-benchmarks x1..xn. Its quite a noisy test, with the results being quite variable. To accurately benchmark, I must reduce that "variability", which requires that I first measure the variability. I can easily...

Analysis of Permutation Finder algorithm(pseudo code)

A SO post about generating all the permutations got me thinking about a few alternative approaches. I was thinking about using space/run-time trade offs and was wondering if people could critique this approach and possible hiccups while trying to implement it in C#. The steps goes as follows: Given a data-structure of homogeneous elem...

How to instantly query a 64Go database

Ok everyone, I have an excellent challenge for you. Here is the format of my data : ID-1 COL-11 COL-12 ... COL-1P ... ID-N COL-N1 COL-N2 ... COL-NP ID is my primary key and index. I just use ID to query my database. The datamodel is very simple. My problem is as follow: I have 64Go+ of data as defined above and in a real-time applic...

problem disabling mod_authz_host to avoid dns lookups

hello, i'm using Debian 4.3.2-1 and Apache 2 in my production server. Watching the logs I noticed apache is resolving client's hostnames with 'HostnameLookups Off' in apache2.conf. I want to avoid these lookups so i'm guessing apache is making this dns queries because i have mod_authz_host enabled. When i try to unlink this module i get...

assembly language and optimization

How can programming in assembly help in achieving optimization ...

C++ Exception Throw/Catch Optimizations

It seems to me that if you have some C++ code like this: int f() { try { if( do_it() != success ) { throw do_it_failure(); } } catch( const std::exception &e ) { show_error( e.what() ); } } The C++ compiler should be able to optimize the throw and catch into almost a simple goto. However, it seems to me from m...

Optimizing quadrant selection

I'm working on a data structure which subdivides items into quadrants, and one of the bottlenecks I've identified is my method to select the quadrant of the point. Admittedly, it's fairly simple, but it's called so many times that it adds up. I imagine there's got to be an efficient way to bit twiddle this into what I want, but I can't t...

Disk reads / seeks on a shared unix server for a directory list

I want to get a better understanding of how disk reads work for a simple ls command and for a cat * command on a particular folder. As I understand it, disk reads are the "slowest" operation for a server/any machine, and a webapp I have in mind will be making ls and cat * calls on a certain folder very frequently. What are "ball park" ...

cache behaviour on redundant writes

Edit - I guess the question I asked was too long so I'm making it very specific. Question: If a memory location is in the L1 cache and not marked dirty. Suppose it has a value X. What happens if you try to write X to the same location? Is there any CPU that would see that such a write is redundant and skip it? For example is there an o...

Optimal extraction of columns from numpy matrix

Say I have a numpy matrix like so: [[ x1, x2, x3, ... ], [ y1, y2, y3, ... ], [ z1, z2, z3, ... ], [ 1, 1, 1, ... ]] From which I want to extract a list of lists like so: [[x1, y1, z1], [x2, y2, z2], [x3, y3, z3], ... ] What is the most optimal way of doing this? At the moment I have: tpoints = [pt[:3].tolist() for pt in nu...

changing float type to short but with same behaviour as float type variable

Is it possible to change the float *pointer type that is used in the VS c++ project to some other type, so that it will still behave as a floating type but with less range? I know that the floating point values never exceed some fixed value in that project, so I want to optimize the program by memory it uses. It doesn't need 4 byte...

Redim boolean Array vs enumerate and set

Hi all, In a case where you would like to reset an array of boolean values what is faster, rediming the array or enumerating and resetting the values? I have run some tests and they seem to suggest that a redim is a lot faster but I am not convinced that it isnt a result of how I’m running the tests. My tests seem to suggest that re...

Is it possible to optimize this function?

Hi, after profiling a lot I found out that this method takes up most of the % of calculation time. I don't really see a way to optimize, since it is a horrible function. (it is...) Maybe someone can show me some nice idea or so? public static double perceivedLoudness(double L_G, double L_ETQ, double a0) { double t1 = 1d + 1 / 4d * Ma...

avoidind a loop in R

I will like to avoid a loop in the following code: delta_S <- function(Ro, Rr, Ir, S1, S2, S3, S4, chromaty) { .... etc .....} for (i in 1:nrow(Rrecon)) { gri[i, 6] <- delta_S(Ro=as.vector(Rrecon[i, ]), Rr=data_base$bck, Ir=data_base$Ir, S1=data_base$s1, S2=data_base$s2, S3=data_base$s3, S4=data_base$s4, chromaty="tetra") } My pr...

C# Property Access Optimization

In C# (or VB .NET), does the compiler make attempts to optimize property accesses? For eg., public ViewClass View { get { ... Something is computed here .... } } if (View != null) View.Something = SomethingElse; I would imagine that if the compiler could somehow detect that View remains con...

best data structure for byIndex and byName retrieval

suppose you need to implement container of a T items, which its value could be retrieved by numeric index (which is random access) and by name (as string). which one is better in term of performance of common operation such as retrieval, adding, and removing the items: (in this case retrieval by index need to be implemented by walking...