optimization

Invalid free while performing a std::string assign with -O2 set in g++

Before I get blasted on opening another question, this question is related to another question that I opened a few days ago: http://stackoverflow.com/questions/2303740/c-program-always-crashes-while-doing-a-stdstring-assign After investigating further based on some of the answers I came up with more questions and more information that ...

How to quickly determine if a method is overridden in Java

There is a possible optimization I could apply to one of my methods, if I can determine that another method in the same class is not overridden. It is only a slight optimization, so reflection is out of the question. Should I just make a protected method that returns whether or not the method in question is overridden, such that a subcla...

How to make my code fast.

Hi, Please can anyone one point me to a good tutorial that helps me to make my code fast and light. I'm interested to know which Method is faster and when to use a method instead of other... And how to evaluate if a code is good or bad? My programming language is C#. Hi all, Thanks for your replies, they are very helpful. I'm editing m...

Checking speed of Android apps without needing physical devices?

I'm writing a game for Android. I'd like to target as many devices as possible. I'm aware that Droid owners buy about 50% of the apps and the rest are a mixture of G1 and HTC devices. So far, I've been testing my app in the emulator set to model the Droid phone (where I get about 40 fps) as well as on an actual Droid phone (where I get ...

Optimization: A tool like gprof for visual studio

As a C# programmer, i'm in a transition from small projects to medium projects. I didn't need a profiler for my little projects before. But now I need a tool that help me improving the performance of my code. I used gprof many years ago, in C. Can someone give me a starting point, or recommend me a tool like gprof for VS2008? That is: A...

Optimization tips and tricks

I need to optimize our web service, but don't know where to begin. We're running GWT, PHP and PostgreSQL. Without even having peaked at any performance data, I'm guessing that the major optimizations are going to happen in the database. I don't know anything about restructuring the DB, nor indexing. (Don't know anything 'bout DBs really...

Rails global content_for

Example: I have 2 partial _map.haml and _bigmap.haml. :: _map.haml - content_for :map do %script{:type => "text/javascript", :src => "http://maps.google.com/maps/api/js?sensor=true"} ... :: _bigmap.haml - content_for :bigmap do %script{:type => "text/javascript", :src => "http://maps.google.com/maps/api/js?sensor=true"} .....

Random Complete System Unresponsiveness Running Mathematical Functions

I have a program that loads a file (anywhere from 10MB to 5GB) a chunk at a time (ReadFile), and for each chunk performs a set of mathematical operations (basically calculates the hash). After calculating the hash, it stores info about the chunk in an STL map (basically <chunkID, hash>) and then writes the chunk itself to another file ...

Unsigned modulos: alternative approach?

I'm in a need to optimize this really tiny, but pesky function. unsigned umod(int a, unsigned b) { while(a < 0) a += b; return a % b; } Before you cry out "You don't need to optimize it", please keep in mind that this function is called 50% of the entire program lifetime, as it's being called 21495808 times for the sm...

In which direction are CSS selectors validated

I remember watching a video a while back online that was a talk given by an engineer at Yahoo and in it he mentioned that CSS selectors are read, by the browser, right to left and not left to right. Meaning #body .header .links a would actually pull out all anchors on the page filtering those with a parent of class links that had a paren...

Optimisation of volatile data querying

I'm trying to solve a problem with latency on a to a mysql-5.0 db. The query itself is extremely simple: SELECT SUM(items) FROM tbl WHERE col = 'val' There's an index on col and there are not more than 10000 values to sum in the worst case (mean of count(items) for all values of col would be around 10). The table has up to 2M rows. The...

select * from table where datetime in month (without breaking index)

I have a bunch of timestamped rows (using the 'datetime' data type) I want to select all the rows that have a timestamp that is within a particular month. The column is indexed so I can't do MONTH(timestamp) = 3 because that'll make this index unuseable. If I have year and month variables (in perl), is there a horrific bit of SQL I ca...

Avoiding unnecessary slice copying in Python.

Is there a common idiom for avoiding pointless slice copying for cases like this: >>> a = bytearray(b'hello') >>> b = bytearray(b'goodbye, cruel world.') >>> a.extend(b[14:20]) >>> a bytearray(b'hello world') It seems to me that there is an unnecessary copy happening when the b[14:20] slice is created. Rather than create a new slice i...

unladen-swallow with numpy/scipy

has anyone used unladen-swallow with numpy/scipy for numeric/scientific applications? Is it significantly faster in your experience? Any opinions would be great. ...

Python code optimization (20x slower than C)

I've written this very badly optimized C code that does a simple math calculation: #include <stdio.h> #include <math.h> #include <stdlib.h> #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) unsigned long long int p(int); float fullCheck(int); int main(int argc, char **argv){ int i, g, maxNumber...

Fastest Way to Delete a Line from Large File in Python

Hi all, I am working with a very large (~11GB) text file on a Linux system. I am running it through a program which is checking the file for errors. Once an error is found, I need to either fix the line or remove the line entirely. And then repeat... Eventually once I'm comfortable with the process, I'll automate it entirely. For n...

need book & web site suggestion for advanced low-level programming

Hello all, I want to learn all advanced details of low-level programming so i want to be able to Learn advanced c/c++ Optimize my code with and without inline assembly Understand the internals of an exe, dll, thread, process Effeciently make use of technologies like SSE, 3DNow, MMX Debug&disassemble executables/libraries and understand w...

Why is WPO(whole-program optimization) not doing any improvements in my program size? (FPC 2.4.0)

I use FPC 2.4.0 for WinXP(binary from the official page), also tryed with same version but compiled from source on my comp. I put something like this: I:\pascal\fpc-2.4.0.source\fpc-2.4.0\compiler\ppc386 -FWserver-1.wpo -OWsymbolliveness -CX -XX -Xs- -al -Os -oServer1.o Server I:\pascal\fpc-2.4.0.source\fpc-2.4.0\compiler\ppc386 -FWser...

Is there a CSS optimizer that will discover identical single properties in selectors and group them together?

Here is an example of what I'd expect: Input: a { background: red; } p { background: red; } strong { background: red; color: green; } Output: strong{color:green;} a,p,strong{background:red;} Most optimisers will output something like this: strong{background:red;color:green;} a,p{background:red;} Notic...

-fomit-frame-pointer, is it safe to use it?

I've seen in many places that people often use the option -fomit-frame-pointer when compiling C / C++ code and I wonder, is the use of that option safe? What is it used for? Thank you very much, best regards. ...