optimization

Are subqueries the only option to reuse variables?

I'd like to use MySQL in this form: SELECT 1 AS one, one*2 AS two because it's shorter and sweeter than SELECT one*2 AS two FROM ( SELECT 1 AS one ) AS sub1 but the former doesn't seem to work because it expects one to be a column. Is there any easier way to accomplish this effect without subqueries? And no, SELECT 2 AS two is no...

Compiler Magic: Why?

I just noticed that given the following code: if (x.ID > 0 && !x.IsCool) the Microsoft C# 3.0 (VS2008 SP1) compiler will optimize it to this: if (!((x.Id <= 0) || x. IsCool)) This is on Debug build without Optimization enabled. Why does the compiler do that? Is it faster in terms of execution? I used Reflector to find that out (I ...

What's the best way to minify the ASP.NET generated Javascript?

What's the best way to minify the ASP.NET generated Javascript, such as the ones served by webresource.axd, in ASP.NET 3.5 at runtime? I tried using the MbCompression module but it's not working with those resources. ...

.Net Runtime Optimization Service Is Turning My System Unstable

Hello, I'm using Windows Vista Ultimate and today I've installed the Visual Studio 2008 SP1, now that I restarted my computer, it's very unstable and when I got in the Task Manager I see that it's taking 88% of my CPU! What I can do to solve this? Thanks. ...

Algorithms for optimizing conjunctive normal form expressions for particular instruction sets?

I'm using Espresso to produce a minimized form of a set of boolean equations. However rather than generating logic for a programmable array logic (which is what Espresso is normally used for), I am looking to implement these on a standard microprocessor. The trouble is that Espresso produces output in conjunctive normal form, which is pe...

How do I optimize these ocaml functions for dynamic interval scheduling?

I have a program that solves the weighted interval scheduling problem using dynamic programming (and believe it or not, it isn't for homework). I've profiled it, and I seem to be spending most of my time filling M with p(...). Here are the functions: let rec get_highest_nonconflicting prev count start = match prev with head :...

C/C++ compiler feedback optimization

Has anyone seen any real world numbers for different programs which are using the feedback optimization that C/C++ compilres offer to support the branch prediction, cache preloading functions etc. I searched for it and amazingly not even the popular interpreter development groups seem to have checked the effect. And increasing ruby,py...

WCF sending huge data

I want to send a huge set of data to a WCF service. The data might consist of thousands od records (entities), depending on the parsed input file. Now the question is: what is the most optimal way to send these data? a. Record by record? By this I will be sure that I won't exceed the maximum allowed message size and I can recover from...

How to use array optimization in boost serialization

I have to serialize an object that contains a std::vector that can contain thousand of members, with that vector sizes the serialization doesn't scale well. According with the documentation, Boost provides a wrapper class array that wraps the vector for optimizations but it generates the same xml output. Diving in boost code, i've found...

Speeding up FCKEditor

Does anyone have a technique for speeding up the FCKEditor? Are there some key JavaScript files that can be minified or removed? ...

How to optimize the space in a A4 sheet?

Hi. I need to put many pictures into a sheet (A4) but I need an algorithm to optimize the space used in order to put the maximum numbers of possible images into the sheet. ...

Performant intersection and distinct element extraction?

I have a line like the following in my code: potentialCollisionsX.Intersect(potentialCollisionsY).Distinct().ToList(); Which, through profiling, i have determined that it is eating approximately 56 percent of my time. I need to figure out how to provide a efficient implementation. I tried List<Extent> probableCollisions = ne...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "misc"-unit: function cwLeftPad(aString:string; aCharCount:integer; aChar:char): string; var i,vLength:integer; begin Result := aString; ...

Compiler optimization: Java bytecode

I'm currently writing a toy compiler targeting Java bytecode in the translation. I would like to know if there is some kind of catalog, maybe a summary, of various simple peephole optimizations that can be made in the emitted bytecode before writing the .class file. I actually am aware of some libraries that have this functionality, but...

JOIN after processing SELECT

Given the following schema: CREATE TABLE players ( id BIGINT PRIMARY KEY, name TEXT UNIQUE ); CREATE TABLE trials ( timestamp TIMESTAMP PRIMARY KEY, player BIGINT, score NUMERIC ); How would I create a SELECT that first finds the best scores from trials, then joins the name field from users? I've been able to get the score...

Google admanager and Jquery

I have Google admanager and Jquery and Jquery UI. But it takes a long time to load the Jquery because Google Admanager. I have about 30 banners in Google Admanager. Anybody know how to get the Jquery load first? Thanks ...

MySQL EXPLAIN: "Using index" vs. "Using index condition"

The MySQL 5.4 documentation, on Optimizing Queries with EXPLAIN, says this about these Extra remarks: Using index The column information is retrieved from the table using only information in the index tree without having to do an additional seek to read the actual row. This strategy can be used when the query us...

Mysterious pointer-related multithreading slowdown

Background: So I'm working on a raytracer.. for my construction of the spatial partitioning scheme, I initially had some code like this: if (msize <= 2) { // create a leaf node Model **models = new Model*[msize]; for (uint i=0; i<msize; ++i) models[i] = &mlist[i]; *arrayPtr = Node(models, msize); // class Node contai...

Appending to a serialized collection

I'm having a serialized array of some type. Is there a way to append new objects to this serialized array (in a serialized form) without the need to read the already saved collection into the memory? Example: I'm having in a file.xml, XML-serialized array of Entity containing 10^12 elements. I need to add another 10^5 elements to the s...

CONTEST: optimize size of grayscale scanned documents!

I put this as a contest, but it's still a question! Here's the original image: http://dl.dropbox.com/u/1663633/original_scan.jpg Original size is about 1 megabyte. How would you reduce the size so that the final print on a A4 paper (about letter size I think..) still looks good? Rules: The process MUST be automatic (to be applied to...