optimization

Optimum way to compare strings in Javascript?

I am trying to optimize a function which does binary search of strings in Javascript. Binary search requires you to know whether the key is == the pivot or < the pivot. But this requires two string comparisons in Javascript, unlike in C like languages which have the strcmp() function that returns three values (-1, 0, +1) for (less than...

Python: Optimizing a tree evaluator

I know tree is a well studied structure. I'm writing a program that randomly generates many expression trees and then sorts and selects by a fitness atribute. I have a class MakeTreeInOrder() that turns the tree into a string that 'eval' can evaluate. but it gets called many many times, and should be optimized for time. below is a ...

Optimal image size for browser rendering

The question Is there a known benchmark or theoretical substantiation on the optimal (rendering speed wise) image size? A little background The problem is as follows: I have a collection of very large images, thousands of pixels wide in each dimension. These should be presented to the user and manipulated somehow. In order to improve ...

Why is String.Concat not optimized to StringBuilder.Append?

OK, so concatenations of constant string expressions are optimized by the compiler into one string. Great. Now with string concatenation of strings only known at runtime, why does the compiler not optimize string concatenation in loops and concatenations of say more than 10 strings to use StringBuilder.Append instead? I mean, it's possi...

Are compilers allowed to eliminate infinite loops?

Can optimizing compiler delete infinite loops, which does not changes any data, like while(1) /* noop */; From analyzing a data flow graph compiler can derive, that such loop is "dead code" without any side effects. Is deleting of infinite loops prohibited by C90/C99 standards? Does C90 or C99 standards permit compiler to deletin...

Is it possible to speed up a sum() in MySQL?

I'm doing a "select sum(foo) from bar" query on a MySQL database that's summing up 7.3mm records and taking about 22 seconds per run. Is there a trick to speeding up sums in MySQL? ...

Is there a way to save the JAVA JIT information for the next run so that i don't have to warm up the code every day?

I have a JAVA process that runs every day and takes about 1,000 or 2,000 hits before it is fully optimized by the JIT. What I'd like to do is save the JIT info so that the next day it can start in an optimized state. It seems like this should be possible, but I have not been able to find any method for doing so. ...

Genetic algorithms

I'm trying to implement a genetic algorithm that will calculate the minimum of the Rastrigin functon and I'm having some issues. I need to represent the chromosome as a binary string and as the Rastrigin's function takes a list of numbers as a parameter, how can decode the chromosome to a list of numbers? Also the Rastrigin's wants the e...

asp.net website optimization for static resources- development vs production deployment - serving static resources from subdomain

I have been looking into optimizing a website and specifically looking into CSS sprites, and serving static resources from a subdomain (static.mysite.com). Reference: Split Components Across Domains We are using cassini (which comes with visual studio) for development and it does not support subdomains. My static resources are contained...

In which cases are IEnumerable<T>.Count optimized?

Using reflector I have noticed that System.Linq.Enumerable.Count method has a condition in it to optimize it for the case when the IEnumerable<T> passed is in fact an ICollection<T>. If the cast succeeds the Count method does not need to iterate over every element, but can call the Count method of ICollection. Based on this I was starti...

How to optimize .NET applications to 64-bit?

In Visual Studio > Build > Configuration Manager you can choose the target platform. What does it change? Is there any other way I can optimize my .NET app when targeting x64 platforms? ...

How to avoid successive deallocations/allocations in C++?

Consider the following code: class A { B* b; // an A object owns a B object A() : b(NULL) { } // we don't know what b will be when constructing A void calledVeryOften(…) { if (b) delete b; b = new B(param1, param2, param3, param4); } }; My goal: I need to maximize performance, which, ...

JS: Most optimized way to remove a filename from a path in a string?

I have strings formatted as follows: path/to/a/filename.txt Now I'd like to do some string manipulation which allows me to very efficiently remove the "filename.txt" part from this code. In other words, I want my string to become this: path/to/a/ What's the most efficient way to do this? Currently I'm splitting the string and reconnect...

gcc optimization, const static object, and restrict

I'm working on an embedded project and I'm trying add more structure to some of the code, which use macros to optimize access to registers for USARTs. I'd like to organize preprocessor #define'd register addresses into const structures. If I define the structs as compound literals in a macro and pass them to inline'd functions, gcc has...

mysql optimization - display 10 most recent records, but also identify duplicate rows

I am new to mysql and I have been pulling my hair out about this problem for days. I need to improve/optimize this query so that it runs faster - right now its taking over 5 seconds. Here is the query: SELECT SQL_NO_CACHE COUNT(*) as multiple, a.*,b.* FROM announcements as a INNER JOIN stores as s ON a.username=s.username ...

ASP.NET PAGE TRACE Results

Hi I am testing a .NET website with Trace Enabled and everything seems normal, to me, except one thing: Category Message From First(s) From Last(s) aspx.page End Load 4,69992678581181 4,699362 This seems like an extraordinarily large number for 'End Load'. I am clueless as to how to use a Trace result correctly, ...

Ideas for good performance optimisations in C++

Ok, I've been sitting in front of profiler results over the last three days, generated by running a pretty wide range of test cases through an automation suite. The idea is to see if there are any good optimisations that can generally improve performance. I'll qualify good in this context as follows; Has the potential for performance...

PHP Objects vs Arrays

I have a huge amount of PHP objects for a neural network for which I have to iterate over and perform some maths on. I was wondering if I would be better off using an associative array over instances of classes? I am dealing with around 3640 objects and iterating around 500 times (at best) on top of that so any micro-optimization helps ...

How can I correlate pageviews with memory spikes?

I'm having some memory problems with an application, but it's a bit difficult to figure out exactly where it is. I have two sets of data: Pageviews The page that was requested The time said page was requested Memory use The amount of memory being used The time this memory use was recorded I'd like to see exactly which pageviews...

Oracle: does the column order matter in an index?

An index on two columns can be created with either of the statements create index foo_ix on foo(a,b); create index foo_ix on foo(b,a); How does this affect the operational (runtime) characteristics of using the index? How does this affect the layout (physical) characteristics of the index? Are either (1) or (2) affected by the types/...