optimization

Different behavior of compilers with array allocation

I recently found a interesting behaviour of g++ when compared with MSVC++ 2008. Consider this tiny program: #include <cstdlib> const int ARR_LENGTH = 512; void doSomething( int iLen ); int main( int argc, char** argv ) { doSomething( ARR_LENGTH ); return 0; } void doSomething( int iLen ) { int iTest[iLen]; return; } ...

scipy smart optimize

I need to fit some points from different datasets with straight lines. From every dataset I want to fit a line. So I got the parameters ai and bi that describe the i-line: ai + bi*x. The problem is that I want to impose that every ai are equal because I want the same intercepta. I found a tutorial here: http://www.scipy.org/Cookbook/Fitt...

Large MyISAM table slow even for non-concurrent inserts/updates

I have a MyISAM table with ~50'000'000 records (tasks for web crawler): CREATE TABLE `tasks2` ( `id` int(11) NOT NULL auto_increment, `url` varchar(760) character set latin1 NOT NULL, `state` varchar(10) collate utf8_bin default NULL, `links_depth` int(11) NOT NULL, `sites_depth` int(11) NOT NULL, `error_text` te...

Minify HTML/PHP

I'm using gzip to compress my html/php files along with js/css/etc. This reduces the payload quite nicely but I also want to 'minify' my markup of both .html and .php pages. Ideally I'd like to control this from a .htaccess file (where I also do the gzipping) rather than the having to include php to each file. I'd like the output to be ...

Some example of __assume leading to a faster code other than "no default" in switch?

Documentation for __assume says "The most common use of __assume is with the default case of a switch statement, as shown in the following example.". Is there any other case where __assume can lead to a more efficient (or even a different) code? When inside of if / else , is compiler automatically "assuming" what is already know becau...

PHP: One giant database class or several smaller classes?

For the current app I am writing I have elected to place all database functionality into a single class, as it allows me to keep the database code away from the business logic and easily replace the database code if we ever have need to switch to another DBMS. However, recently my database class has become rather large (EDIT for info: a...

Mysql optimization for select query with IN() clause inside where clause (explain output given)

I have this query:- SELECT SUM(DISTINCT( ttagrels.id_tag IN ( 1816, 2642, 1906, 1398, 2436, 2940, 1973, 2791, 1389 ) )) AS key_1_total_matches, IF(( od.id_od > 0 ), COUNT(DISTINCT( od.id_od )), 0) AS tutor_popularity, td.*, u.* FROM tutor_deta...

PostgreSQL slow on a large table with arrays and lots of updates

I have a pretty large table (20 mln records) which has a 3 column index and an array column. The array column is updated daily (by appending new values). There is also inserts, but not as much as updates. The data in the array represents daily measurements corresponding to the three keys, something like this: [[date_id_1, my_value_for_d...

Scattered-write speed versus scattered-read speed on modern Intel or AMD CPUs?

I'm thinking of optimizing a program via taking a linear array and writing each element to a arbitrary location (random-like from the perspective of the CPU) in another array. I am only doing simple writes and not reading the elements back. I understand that a scatted read for a classical CPU can be quite slow as each access will cause...

Fitting a binormal distribution in R

As from title, I have some data that is roughly binormally distributed and I would like to find its two underlying components. I am fitting to the data distribution the sum of two normal with means m1 and m2 and standard deviations s1 and s2. The two gaussians are scaled by a weight factor such that w1+w2 = 1 I can succeed to do this u...

Optimise SQL query joined on DATE(datetime) = date?

I have two tables: one has a datetime column, the other has a date column. I want to join the two tables like this: SELECT t1.dt, t2.d FROM table1 t1, JOIN table2 t2 ON DATE(t1.dt) = t2.date But obviously, this kills the index on t1.dt. What's the best strategy to get around this? The simplest approach would be to add a ne...

Optimize algorithm for creating a list of items rated together, in Python.

given a list of purchase events (customer_id,item) 1-hammer 1-screwdriver 1-nails 2-hammer 2-nails 3-screws 3-screwdriver 4-nails 4-screws i'm trying to build a data structure that tells how many times an item was bought with another item. Not bought at the same time, but bought since I started saving data. the result would look like ...

How to compress HTTP response headers?

At the Velocity 2010 conference, Google said that header compression can yield big gains: Hölzle noted a glaring inefficiency in the handling of web page headers, which provide information about a user’s IP address, browser and other session data. The average web page makes 44 calls to different resources, with many of those requests...

How can I tell if cookies are being set on my domain?

I've been doing a lot of reading on how to optimize website performance. Both Google and Yahoo advocate using cookie-less domains; I've also read about setting up subdomains to achieve the same effect. My question is: is there a way to determine if cookies are being set at the *.example.com level versus the www.example.com level? I have...

efficiency of multiple canvas size increases in silverlight

Hi, I'm writing a silverlight app which does some real-time charting. Basically, I just have some polylines overlaid on a canvas. The user can record data for arbitrary amounts of time, and so the width of the canvas is increasing as necessary. Since the canvas is wrapped inside a scrollviewer, it can get quite large. Haven't seen a...

form optimization websites/services?

Looking for a really simple form optimization service/software something like crazyegg.com for my forms or google optimizer. I want to test removing fields and compare conversions, see where I lose most people filling out a form etc Thanks ...

Interesting graph traversal optimization problem

Suppose you have a set of nodes connected into a tree structure with one root node and any node may have any number of child nodes. You can only traverse the tree starting at the root node or from your current position along direct connections. I.e., no random access to a specific node, but the structure of the graph is already known an...

programmatically optimizing expressions (by removing redundant computations)

I had a pretty big equation that I needed to use to solve for a given variable. So I used an online tool that was capable of rewriting an equation in terms of a given variable. It gave me some huge 700 character equation. I tested it, and it does work. I can see some pretty obvious redundancies in the equation where it's recomputing a v...

Optimizing OpenGL ES on the iPhone and interpreting Instruments

I'm trying to push my FPS up on iPhone 3Gs from 30 as high as possible... and I'm running into a couple of issues and thought it would be better to ask for advice. 1) What exactly do the Renderer Utilization and Tiler Utilization columns on the OpenGL ES Instrument signify? My Tiler Utiliation percentage is extremely low, and my Rendere...

How to speed up my app for the iPad?

Application Specific Information: com.oneorangetree.iphoneexample failed to launch in time elapsed total CPU time (seconds): 3.500 (user 1.680, system 1.820), 17% CPU elapsed application CPU time (seconds): 0.920, 5% CPU When the app loads, it does ALOT of stuff in viewDidLoad It takes about 30 seconds to complete. How can I put thi...