optimization

How expensive are function calls in JavaScript?

I've been looking at other people's JavaScript code, and I've noticed that many programmers tend to create functions that could be combined with the functions that are calling them. One example is this; the 'initWebGL' function could be combined with the 'start' function and it'd function the same. Another example is in the source of thi...

Multiple Origins - Multiple Destinations

I either have a blonde moment or am attempting something a bit out of my league, but here it goes ;) I have an optimization question. It is only somewhat traveling-salesman-ish. Lets say I have a set of destinations and another corresponding set of origins. I need to link each destination with one origin so that the variation between...

Speeding up conversion from MyISAM to InnoDB

I have a MySQL 1.5 GB MyISAM-table (1.0 GB data, 0.5 GB indexes) in production which I'm about to convert into InnoDB. Since the table is used in production I'd like to make the downtime as short as possible. My questions: What MySQL configuration options should be adjusted in order to speed up ALTER TABLE table_name ENGINE=InnoDB;? ...

Optimization of MySQL search using "like" and wildcards

How can queries like SELECT * FROM sometable WHERE somefield LIKE '%value%' be optimized? The main issue here is the first wildcard which prevents DBMS from using index. Edit: What is more, somefield value is solid string (not a piece of text) so fulltext search could not be performed. ...

Optimizing for space instead of speed in C++

When you say "optimization", people tend to think "speed". But what about embedded systems where speed isn't all that critical, but memory is a major constraint? What are some guidelines, techniques, and tricks that can be used for shaving off those extra kilobytes in ROM and RAM? How does one "profile" code to see where the memory bloat...

Best Practice for Transitioning From Nested State to Nested State (see diagram)

I am trying to wrap my mind around the best way to implement nested state transitions in a single threaded programming language (Actionscript). Say I have a structure like this behavior tree: Now imagine that each leaf node is a destination point on a website, like an image in a gallery, or a comment nested in a post view nested in a ...

Fast (lowlevel) method to recursively process files in folders

My application indexes contents of all hard drives on end users computers. I am using Directory.GetFiles and Directory.GetDirectories to recursively process the whole folder structure. I am indexing only a few selected file types (up to 10 filetypes). I am seeing in profiler that most of the indexing time is spent in enumerating files a...

Optimizing multiple joins

Hi folks, I'm trying to figure out a way to speed up a particularly cumbersome query which aggregates some data by date across a couple of tables. The full (ugly) query is below along with an EXPLAIN ANALYZE to show just how horrible it is. If anyone could take a peek and see if they can spot any major issues (which is likely, I'm not ...

Mysql Sub Select Query Optimization

I'm running a query daily to compile stats - but it seems really inefficient. This is the Query: SELECT a.id, tstamp, label_id, (SELECT author_id FROM b WHERE b.tid = a.id ORDER BY b.tstamp DESC LIMIT 1) AS author_id FROM a, b WHERE (status = '2' OR status = '3') AND category != 6 AND a.id = b.tid AND (b.type = 'C' OR b.type = 'R') AN...

Fast Sin/Cos using a pre computed translation array

Hi, I have the following code doing Sin/Cos function using a pre-calculated memory table. in the following example the table has 1024*128 items covering all the Sin/Cos values from 0 to 2pi. I know I can use Sin/Cos symmetry and hold only 1/4 of the values but them I will have more 'ifs' when computing the value. private const double P...

A good way to display large images online

I need to show an image that is 4000x6000 px. What are your experiences with displaying large images online? My initial idea was to use the GMap cutter and the Google Maps API to show the image. GMap Cutter takes an image and cuts it appropriately for use as a google map. My problem with approach is that the image will be changing often...

Services to suggest changes in markup to improve search-engine friendliness (think W3Cs validation services)

Are there any services out there, that can parse a website and give some sort of feedback to how search-engine friendly that website is? And perhaps even suggest changes to the mark-up to improve indexing? Think W3Cs validation services. ...

Are there any optimisations for retrieving of return value in Delphi?

I'm trying to find an elegant way to access the fields of some objects in some other part of my program through the use of a record that stores a byte and accesses fields of another record through the use of functions with the same name as the record's fields. TAilmentP = Record // actually a number but acts like a pointer private Ord...

The difference background in image viewer of Android

Hi, I do these actions on Android G1 2 times: open gallery -> view image -> Capture screen-shot -> Go back -> exist from gallery. But captured screen-shots of 2 times are difference: the above and below background of image viewer of first time is lighter Grey, while second time is darker. 2 screen-shots: First time: http://farm5.stati...

Optimizing a MySQL query with a large IN() clause or join on derived table

Let's say I need to query the associates of a corporation. I have a table, "transactions", which contains data on every transaction made. CREATE TABLE `transactions` ( `transactionID` int(11) unsigned NOT NULL, `orderID` int(11) unsigned NOT NULL, `customerID` int(11) unsigned NOT NULL, `employeeID` int(11) unsigned NOT NULL, ...

Is it a good practice to do optimization during initial coding?

Is it a good practice to follow optimization techniques during initial coding itself or should one concentrate purely on realization of functionality first? If one concentrates purely on functionality during initial coding, then how easy or difficult is it to take care of optimization later on? ...

optimizing byte-pair encoding

Noticing that byte-pair encoding (BPE) is sorely lacking from the large text compression benchmark, I very quickly made a trivial literal implementation of it. The compression ratio - considering that there is no further processing, e.g. no Huffman or arithmetic encoding - is surprisingly good. The runtime of my trivial implementation ...

sequential strpos() faster than a function with one preg_match?

i need to test if any of the strings 'hello', 'i am', 'dumb' exist in the longer string called $ohreally, if even one of them exists my test is over, and i have the knowledge that neither of the others will occur if one of them has. Under these conditions I am asking for your help on the most efficient way to write this search, strpos(...

Populating droplist in ASP.NET with SQL Server takes a long time. Any optimizations?

One of my web pages populates a droplist with about 60k items pulled from SQL Server, and this operation takes upwards of 10 seconds to complete. Are there some tricks or optimizations I can try to improve performance? I'm using a SqlDataSource configured as a DataReader. Thanks for any help. ...

How to optimize neural network by using genetic algorithm?

I'm quite new with this topic so any help would be great. What i need is to optimize a neural network in MATLAB by using GA. My network has [2x98] input and [1x98] target, i've tried consulting matlab help but im still kind of clueless about what to do :( so, any help would be appreciated. Thanks in advance. edit: i guess i didn't say w...