optimization

Is life-time of local variables in a function, necessarily equal to life-time of that function's execution ?

Possible Duplicate: how does an optimizing c++ compiler reuse stack slot of a function? do c++ compilers have their ways to determine the time at which, life-time of each local variable in a function ends so that they optimize using stack memory, or they simply take it equal to life-time of the function execution ? ...

Open source alternative to Mosek?

Is there an open source alternative to Mosek? Basically, I'm looking for large scale convex optimization solver packages. Thanks! EDIT: Forgot to mention earlier, problem is non-linear; mostly quadratic, but occasionally may need non-quadratic constraints + non-quadratic objective ...

Java String Comparison: style choice or optimization?

I've been taking a look at some GWT code written by various people and there are different ways of comparing strings. I'm curious if this is just a style choice, or if one is more optimized than another: "".equals(myString); myString.equals(""); myString.isEmpty(); Is there a difference? ...

Selecting an optimum set according to ranked criteria

I am given a string, and a set of rules which select valid substrings by a process which isn't important here. Given an enumeration of all valid substrings, I have to find the optimum set of substrings according to a set of ranked criteria, such as: Substrings may not overlap All characters must be part of a substring if possible Use a...

How do you identify unused indexes in a MySQL database?

I have recently completely re-written a large project. In doing so, I have consolidated great number of random MySQL queries. I do remember that over the course of developing the previous codebase, I created indexes on a whim, and I'm sure there are a great number that aren't used anymore. Is there a way to monitor MySQL's index usage...

C++ optimization question

Hello! I have some mid-large project that is actively using boost libraries and, hence, suffers in terms of Debug application performance (Visual Studio 2008). Solution that I use right now means turning on function inlining even in Debug mode, which brings enough performance, but should definitely have some drawbacks. Does anyone kno...

Dereferencing type-punned pointer will break strict-aliasing rules

Hi there, I used the following piece of code to read data from files as part of a larger program. double data_read(FILE *stream,int code) { char data[8]; switch(code) { case 0x08: return (unsigned char)fgetc(stream); case 0x09: return (signed char)fgetc(stream); case 0x0b:...

Optimizing an inner loop calculation in Mathematica

Hi all, I'm currently doing some computation in Mathematica related to Quantum Mechanics. As we've moved from a 1D to 2D lattice model, the problem size is becoming problematic Currently, we have a summation that looks something like this: corr[r1_, r2_, i_, j_] = Sum[Cos[f[x1, x2] Angle[i] r1 + f[y1, y2] Angle[j] r2], {x1, HL}, {x2, H...

Time Profiler: Optimizing UIImageView alloc/init calls

Time Profiler says that statements like these are slowing my app down. Is there a better way to write this so that my app runs faster? background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myfolder.png"] highlightedImage:[UIImage imageNamed:@"myfolderOFF.png"]]; Thanks ...

is there a tricky way to optimize this query

I'm working on a table that has 3008698 rows exam_date is a DATE field. But queries I run want to match only the month part. So what I do is: select * from my_big_table where to_number(to_char(exam_date, 'MM')) = 5; which I believe takes long because of function on the column. Is there a way to avoid this and make it faster? other ...

Fast undo/redo with memento/command pattern?

I'm writing a painting/graphics Java application for a mobile phone (so memory is limited). The application state is essentially three 1000x500 bitmaps (i.e. layers of a painting). Loading three bitmaps takes about 2 or 3 seconds. I'm trying to write an undo engine but I just cannot work out a good way to do it. The typical approaches a...

How well does the Visual C++ 2008/2010 compiler optimize?

Im just wondering how good the MSVC++ Compiler can optimize code(with Code examples) or what he can't optimize and why. For example i used the SSE-intrinsics with something like this(var is an __m128 value)(it was for an frustrum-culling test): if( var.m128_f32[0] > 0.0f && var.m128_f32[1] > 0.0f && var.m128_f32[2] > 0.0f && var.m128_f...

count() query taking more than 20 seconds

Table_a = 7022536 rows Table_b (GTT) = 5601 rows Query: SELECT COUNT (a.ssn_head) FROM table_a a, table_b b WHERE b.hoh = a.head AND a.flag = 'Y'; takes 20+ seconds to bring 17214 records. Explain plan is: Plan hash value: 1901401324 -------------------------------------------------------------------------------- | Id |...

What is the alternative to preallocating arrays in MATLAB?

Possible Duplicate: Growable data structure in MATLAB So in my current MATLAB script, I have a very large indeterminate-sized growing array. There is currently nothing I can do about it, because if I actually preallocate, it would take many many many times more memory than it should need (maximum possible amount of values is 6...

How do I use SSE(1,2,3,4) optimizations?

I'm wondering if simply compiling my msvc project with sse/sse2 will have any effect. I do for example vector normalization and dot product but I do these wth math, not any specific function. Is there like sse_dot() and sse_normalize() that I should be using to actualyy take advantage, or will the compiler know? Thanks ...

SQL - select first in value set by priority?

I'm fairly inexperienced in SQL and this seems like it must be an easy task, but I'm not sure how to go about it. Basically I want to select a single row from table A where field "someField" is in a pre-determined set "someSet", but I want it to look for each value in the set individually. For example, let's say "someSet" contains 5, 6,...

Update a rectangular region in a drawing.

I paint a drawing on a drawing area. In order to optimize the performance of that drawing I decided to redraw only inside the really necessary region(clipping region). See the picture. The problem is that I don't arrive to build a method(GetBitmapFromRectangle) that returns me the result of intersection of my paths with the clipping r...

What is the most efficient way to read a big text file backwards?

What is the most efficient way to read a big text file backwards, line by line, using Windows API functions? For example, if a file is: line 1 ... line 108777 line 108778 the output should be: line 108778 line 108777 ... line 1 I want to write a C program for this. You don't need to write a code (but if you want, that's great), I a...

How to generate better SQL from Linq2Sql query

I have the following query: var data = from d in dc.GAMEs where (d.GAMEDATE + d.GAMETIME.Value.TimeOfDay) >= DateTime.Now select d; This generates some horendous looking SQL, looking something like this: SELECT {...} WHERE DATEADD(ms, ((CONVERT(BigInt,((CONVERT(BigInt,DATEPART(HOUR, [t0].[GAMETIME]))) * 36000000000) + ((CONVERT...

Whats the most efficient way to store an array of integers in a MySQL column?

I've got two tables A: plant_ID | name. 1 | tree 2 | shrubbery 20 | notashrubbery B: area_ID | name | plants 1 | forrest | *needhelphere* now I want the area to store any number of plants, in a specific order and some plants might show up a number of times: e.g 2,20,1,2,2,20,1 Whats the most effic...