optimization

How to optimize quartz 2d?

I have a block of code that's essentially: for(int i=0;i<aInt;i++){ CGPoint points[2] = {CGPointMake(i,0),CGPointMake(i,bArray[i])}; CGContextStrokeLineSegments(myContext, points, 2); } which is causing a bit of a bottleneck when aInt gets large, as it's likely to do in my case. I don't know enough about quartz...

There's got to be an easier way of dealing with arrays!

To optimize a bottleneck, I converted the creation of a large NSArray to a c-style array. (The resulting creation was 1/8 the time of the original NSArray version. Yeah!) But once it's created, speed is no longer an issue, so I'd rather benefit from it being an NSArray again. However, it seems ridiculously involved to convert a c-style...

Optimizing performance on Erlang processes

Hi all, In a test I'm building here my goal is to create a parser. So I've built a concept proof that reads all messages from a file, and after pushing all of them to memory I'm spawning one process to parse each message. Until that, everything is fine, and I've got some nice results. But I could see that the erlang VM is not using all ...

Optimisation , Compilers and Its Effects

(i) If a Program is optimised for one CPU class (e.g. Multi-Core Core i7) by compiling the Code on the same , then will its performance be at sub-optimal level on other CPUs from older generations (e.g. Pentium 4) ... Optimizing may prove harmful for performance on other CPUs..? (ii)For optimization, compilers m...

ComboBox to sorted Xml file. Need help to optimize.

I wrote a method that sorts values of a ComboBox and then saves them into Xml file. I'm very unhappy how it looks. Please feel free to take it apart and help me optimize it. The method looks very similar to this one: public void Save(ComboBox comboBoxItems) { var xmlElements = new XElement("Root"); List<string> children = n...

C# : compiling with /debug+ /debug:pdbonly /optimize- is optimizing the runtime code.

is it a bug? here is the code static void Main(string[] args) { fun1(); } static void fun1() { fun2(); } static void fun2() { throw new Exception("test exception"); } build with the above option in VS 2008, with Optimize option not selected and Build advanced options debug info select pdbonly and check the stacktrace. let me k...

VC++ SSE intrinsic optimisation weirdness

I am performing a scattered read of 8-bit data from a file (De-Interleaving a 64 channel wave file). I am then combining them to be a single stream of bytes. The problem I'm having is with my re-construction of the data to write out. Basically I'm reading in 16 bytes and then building them into a single __m128i variable and then using...

Rules for using the restrict keyword in C?

I'm trying to understand when and when not to use the restrict keyword in C and in what situations it provides a tangible benefit. After reading, "Demystifying The Restrict Keyword", ( which provides some rules of thumb on usage ), I get the impression that when a function is passed pointers, it has to account for the possibility that t...

Tool for detecting pointer aliasing problems in C / C++

Is there a tool that can do alias analysis on a program and tell you where gcc / g++ are having to generate sub-optimal instruction sequences due to potential pointer aliasing? ...

Optimize SQL query that uses NOT EXISTS with many columns in not exists' WHERE clause

Edit: using SQL Server 2005. I have a query that has to check whether rows from a legacy database have already been imported into a new database and imports them if they are not already there. Since the legacy database was badly designed, there is no unique id for the rows from the legacy table so I have to use heuristics to decide wh...

ASM-optimizations lost after compilation?

Not that I'm in that situation currently, but I'm just interested in the answer... Assuming you have some code written in C/C++ and you want to manually optimize it by modifying it in ASM. What happens if you alter the code in C/C++ and recompile from source. Sure, the optimization on the just compiled file is lost. How do you avoid th...

Will GCC inline a function that takes a pointer?

I have a function which operates on piece of data (let's say, an int), and I want to change it in place by passing a reference to the valule. As such, I have the function: void myFunction(int *thing) { ... }. When I use it I call it thus: myFunction(&anInt). As my function is called frequently (but from many different places) I am conc...

Is MySQL performant with select ... in (ID1,ID2,ID3,...ID100)?

Will this kind of query bring performance issue? ...

World nations on one php array, better if static?

I'm working on a site where the user can select his country, for now I've created an array which contains alla nation names and relative codes like it code for Italy: <?php $nations[] = array ("code" => "af", "name" => "Afghanistan"); $nations[] = array ("code" => "ax", "name" => "Aland Islands"); $nations[] = array ("code" => "al", "na...

Using python's map() with multiple args?

Okay, so I've got a piece of Python code which really needs optimizing. I need to iterate over every single pixel of a small (80x60) image and extract the RGB values from it. The code in the loop itself isn't too slow, but I'm doing it using nested for loops, which I assume add quite a bit of overhead... xr = xrange(80) yr = xrange(60)...

Size optimizations for Assembly

What other optimizations, like the one presented here http://stackoverflow.com/questions/147173/x86-assembly-testl-eax-against-eax can one apply in order to reduce code size? I am interested especially in one-line optimizations like using test eax, eax instead of cmp eax, 0. Thanks. ...

Optimize function to sort a list of tuples

I need to sort a list of tuples by first item in descending order, and then by second item in ascending order. To do this, I have implemented the following function, but I think it could be faster. >>> compare = lambda a, b: -cmp(b[1], a[1]) if b[0] == a[0] else cmp(b[0], a[0]) >>> sorted([(0, 2), (0, 1), (1, 0), (1, 2)], cmp=compare) ...

explicit copy constructor or implicit parameter by value

I recently read (and unfortunately forgot where), that the best way to write operator= is like this: foo &operator=(foo other) { swap(*this, other); return *this; } instead of this: foo &operator=(const foo &other) { foo copy(other); swap(*this, copy); return *this; } The idea is that if operator= is called with...

Improve SQL query: Cumulative amounts over time

Suppose I have a SQL table of Awards, with fields for Date and Amount. I need to generate a table with a sequence of consecutive dates, the amount awarded in each day, and the running (cumulative) total. Date Amount_Total Amount_RunningTotal ---------- ------------ ------------------- 1/1/2010 100 ...

Smaller instruction than "add esp, 4"

Me again. I'm having a lot of "add esp, 4" in my program and I'm trying to reduce its size. Is there any smaller instruction that can replace "add esp, 4" ? ...