While looking at a micro-optimization question that I asked yesterday (here), I found something strange: an or statement in Java is running slightly faster than looking up a boolean value in an array of booleans.
In my tests, running the below algorithms on long values from 0 to 1 billion, alg1 is about 2% faster. (I have altered the ...
Does anyone know a good tool that can be run on a page (for asp.net, for example) to help to minimize the footprint size of the page?
The page will have typical items: HTML, Javascript, etc.
I've heard of Javascript crunchers in the past, that will make the size of the code as compact as possible (and obfuscate it, I suppose).
The goa...
Is there any performance advantage to using lists over dictionaries over tuples in Python?
If I'm optimising for speed, is there any reason to prefer one over another?
...
I have an array (arr) of elements, and a function (f) that takes 2 elements and returns a number.
I need a permutation of the array, such that f(arr[i], arr[i+1]) is as little as possible for each i in arr. (and it should loop, ie. it should also minimize f(arr[arr.length - 1], arr[0]))
Also, f works sort of like a distance, so f(a,b) ...
I am working on lock free structure with g++ compiler. It seems that with -o1 switch, g++ will change the execution order of my code. How can I forbid g++'s optimization on certain part of my code while maintain the optimization to other part? I know I can split it to two files and link them, but it looks ugly.
...
I have an idea about what it is. My question is :-
1.) If i program my code which is amenable to Tail Call optimization(Last statement in a function[recursive function] being a function call only, no other operation there) then do i need to set any optimization level so that compiler does TCO. In what mode of optimization will compiler ...
NOTE: the original question is moot but scan to the bottom for something relevant.
I have a query I want to optimize that looks something like this:
select cols from tbl where col = "some run time value" limit 1;
I want to know what keys are being used but whatever I pass to explain, it is able to optimize the where clause to nothing...
We all know that premature optimization is the root of all evil because it leads to unreadable/unmaintainable code. Even worse is pessimization, when someone implements an "optimization" because they think it will be faster, but it ends up being slower, as well as being buggy, unmaintainable, etc. What is the most ridiculous example of...
I'm working with some number crunching code that, by its nature, is floating-point intensive and and just plain slow. It's research code, so it can be tailored to one architecture, and is running on a Core 2 Quad box. My understanding is that, for the Pentium 4/Netburst architecture, Intel severely stripped down the x87 FPU, and adopte...
I have a table which consists of 200 Companies Stock prices for 5 years. This is one large table which consists of Company Name, Stock Open, High, Low, Close, Date
I am now required to do some processing on the same and also let users [up to 10] access this database to fetch reports on different sets of parameters and queries.
Should I...
Please enlighten me:
Which one do you prefer? Why? [Readability? Memory concern? Some other issues?]
1.
String strSomething1 = someObject.getSomeProperties1();
strSomething1 = doSomeValidation(strSomething1);
String strSomething2 = someObject.getSomeProperties2();
strSomething2 = doSomeValidation(strSomething2);
String strSomeResult ...
Our build is dog slow. It uses nested gnu makefiles on linux. It creates three builds for three different targets from the same source tree. It uses symlinks to point to each of the three parallel directory trees in turn. We can do partial builds by using make inside subdirectories, which saves time, but if our work spans multiple direct...
I have a very large background image (about 940x940 pixels) and I'm wondering if anyone has tips for compressing a file this large further than Photoshop can handle? The best compression without serious loss of quality from Photoshop is PNG 8 (250 KB); does anyone know of a way to compress an image down further than this (maybe compress...
I have a table of the form
CREATE TABLE data
{
pk INT PRIMARY KEY AUTO_INCREMENT,
dt BLOB
};
It has about 160,000 rows and about 2GB of data in the blob column (avg. 14kb per blob). Another table has foreign keys into this table.
Something like 3000 of the blobs are identical. So what I want is a query that will give me a re m...
HI, im having trouble trying to optimize the following query for sql server 2005. Does anyone know how could i improve it. Each one of the tables used there have about 40 million rows each. I've tried my best trying to optimize it but i manage to do the exact opposite.
Thanks
SELECT
cos
, SIN
FROM
ConSisHis200...
Raymond Chen has this to say on his recent post on code optimizations... Obvious optimizations - one that begs to be optimized - tend to be "de-optimizations" if you consider all that need to be considered...
I'm sure you must have come across / even coded optimizations you were embarrassed about after you learnt more...
Care to sha...
You are given a heap of code in your favorite language which combines to form a rather complicated application. It runs rather slowly, and your boss has asked you to optimize it. What are the steps you follow to most efficiently optimize the code?
What strategies have you found to be unsuccessful when optimizing code?
Re-writes: At wh...
In the past, and intermittently now, I've used simulation tools like Easy Java Simulations and NetLogo.
They are great tools for visually modeling various mathematical/comp-sci concepts because "all you have to do" is write the simulation loop - the graphics, etc are handled for you.
However, one thing I have noticed is that improving ...
I am working on a program which manipulates images of different sizes. Many of these manipulations read pixel data from an input and write to a separate output (e.g. blur). This is done on a per-pixel basis.
Such image mapulations are very stressful on the CPU. I would like to use multithreading to speed things up. How would I do th...
I understand how Map is easily parallelizable - each computer/CPU can just operate on a small portion of the array.
Is Reduce/foldl parallelizable? It seems like each computation depends on the previous one. Is it just parallelizable for certain types of functions?
...