optimization

Is it still worth trying to create optimizations for sqrt() in C?

Are the old tricks (lookup table, approx functions) for creating faster implementations of sqrt() still useful, or is the default implementation as fast as it is going to get with modern compilers and hardware? ...

Fastest way to draw bitmasked images in OpenGL

With modern hardware, what is the fastest way to draw an image with a "bitmask", i.e., a mask that specifies whether a given pixel will be drawn or not (this could be extracted from "magic pink" pixels, for example) using OpenGL? Should I just use alpha blending and set invisible pixels to a=0? Should I use the old "AND black/white mask...

Getting SQL to use the correct index

I have a table with two indexes, one of which is the faster covering index for a certain query. However, mySQL (5.1) is not choosing the correct index. I have looked at the explain for this query and done some speed tests and it makes a big difference if you force the key. Is there any way of examining how it picks the index and what cr...

Optimizing SELECT Query on Oracle 10 Dense Unique Index

I have a table in Oracle 10 with following structure Create Table Bookmarks( BOOKMARKID NUMBER(10,0) NOT NULL PRIMARY KEY, URL VARCHAR2(4000 CHAR) NOT NULL UNIQUE ) URL has a unique constraint set thus a unique index. There are about 1 million records in this table. I have to frequently check if a bookmark already exists in ...

Performance optimization strategies of last resort?

There are plenty of performance questions on this site already, but it occurs to me that almost all are very problem-specific and fairly narrow. And almost all repeat the advice to avoid premature optimization. Let's assume: the code already is working correctly the algorithms chosen are already optimal for the circumstances of the pr...

Optimizing Flex application - Where to find my bottlenecks

My Flex web application is almost ready for launch. I'm currently optimizing as much as I can in order to make sure even low-end clients are able to run it fluently. The problem is, I have no idea where to optimize more than I've already optimized. My question is, what are the usuals suspects regarding bottlenecks? What tips and experie...

Optimizing an embedded SELECT query in mySQL

Ok, here's a query that I am running right now on a table that has 45,000 records and is 65MB in size... and is just about to get bigger and bigger (so I gotta think of the future performance as well here): SELECT count(payment_id) as signup_count, sum(amount) as signup_amount FROM payments p WHERE tm_completed BETWEEN '2009-05-01' AND ...

n-th prime number problem, need to speed it up a bit

There is simple cipher that translates number to series of . ( ) In order to encrypt a number (0 .. 2147483647) to this representation, I (think I) need: prime factorization for given p (p is Prime), order sequence of p (ie. PrimeOrd(2) == 0, PrimeOrd(227) == 49) Some examples 0 . 6 (()()) 1 () ...

Check this web optimization report - how can I fix it?

Hi guys I ran the analyser on http://www.websiteoptimization.com/services/analyze/ and I got a number of issues the most prominent are the ones below: *TOTAL_OBJECTS - Warning! The total number of objects on this page is 93 which by their number will dominate web page delay. Consider reducing this to a more reasonable number. Above 20...

What are the best data structure for mapping strings to values?

I'm interested in an answer that explain the best in each situation. In particular which is best for: few values lots of values many values with only few extensively used read only or nearly read only map write-a-lot map fast membership without retrieval memory footprint with large value others ...

Should I normalize my DB or not?

When designing a schema for a DB (e.g. MySQL) the question arises whether or not to completely normalize the tables. On one hand joins (and foreign key constraints, etc.) are very slow, and on the other hand you get redundant data and the potential for inconsistency. Is "optimize last" the correct approach here? i.e. create a by-the-bo...

Parallelization: pthreads or OpenMP?

Most people in scientific computing use OpenMP as a quasi-standard when it comes to shared memory parallelization. Is there any reason (other than readability) to use OpenMP over pthreads? The latter seems more basic and I suspect it could be faster and easier to optimize. ...

How to resize image in C# without smoothing

How do you re-size a black and white image without any smoothing affect? I have a BarCode that is an image that is too big. I need to resize the image but with one caveat. The resulting image needs to be the same proportional size and the black and white bars can not turn into black,grey and white bars(which I believe is due to some ...

What kind of optimizations do both the C# compiler and the JIT do?

I'm continuing my work on my C# compiler for my Compilers Class. At the moment I'm nearly finished with the chapters on Compiler Optimizations in my textbook. For the most part, my textbook didn't have Just-In-Time compilation in mind when it was written and I'm curious about the kinds of static, pre-jit optimizations the C# compiler...

database design asking for advice

Hello everyone, I need to store entries of the schema like (ID:int, description:varchar, updatetime:DateTime). ID is unique primary key. The usage scenario is, I will frequently insert new entries, frequently query entries by ID and less frequently remove expired entries (by updatetime field, using another SQL Job run daily to avoid dat...

Lazy loading the addthis script? (or lazy loading external js content dependent on already fired events)

I want to have the addthis widget available for my users, but I want to lazy load it so that my page loads as quickly as possible. However, after trying it via a script tag and then via my lazy loading method, it appears to only work via the script tag. In the obfuscated code, I see something that looks like it's dependent on the DOMCont...

Java Optimizations

Hi, I am wondering if there is any performance differences between String s = someObject.toString(); System.out.println(s); and System.out.println(someObject.toString()); Looking at the generated bytecode, it seems to have differences. Is the JVM able to optimize this bytecode at runtime to have both solutions providing same perfor...

gcc optimization flags for Xeon?

Hi, I'd want your input which gcc compiler flags to use when optimizing for Xeons? There's no 'xeon' in mtune or march so which is the closest match? ...

How to write efficient Java code?

As all of you may know, Java code is compiled and interpreted by JVMs. My questions deal with optimization: Is it optimized at run-time by the JVM only or also at compile-time? In order to write efficient code, where can I find the list of supported optimizations? Or are JVM optimizations powerful enough so that I just have to write co...

Efficient way to generate random contingency tables?

What is an efficient way to generate a random contingency table? A contingency table is defined as a rectangular matrix such that the sum of each row is fixed, and the sum of each column is fixed, but the individual elements may be anything as long as the sum of each row and column is correct. Note that it's very easy to generate rando...