optimization

Minify Html output of ASP.NET Application

What are the ways by which we can reduce the size of the HTML Response sent by an asp.net application? I am using Controls which are not owned by me and it produces output with white spaces. I am interested in Minifying the entire HTML output of the page just like how google does (View source www.google.com) to improve the timing. Is t...

How do I figure out what -O<num> options do in gcc?

I seem to remember being able to print out (or locate) the specific switches that each -O<num> option turns on. Can you remind? Thanks! ...

How can I increase the performance in a map lookup with key type std::string?

I'm using an std::map (VC++ implementation) and it's a little slow for lookups via the map's find method. The key type is an std::string. Can I increase the performance of this std::map lookup via a custom key compare override for the map? For example, maybe std::string < compare doesn't take into consideration a simple string::size()...

Using IN or a text search

I want to search a table to find all rows where one particular field is one of two values. I know exactly what the values would be, but I'm wondering which is the most efficient way to search for them: for the sake of example, the two values are "xpoints" and "ypoints". I know for certain that there will be no other values in that field...

Advice on removing multiple sub-queries (which contains a join) by optimizing Linq To SQL query

I'm working on adding globalization to my product cataloge and I have made it work. However, I feel that the underlaying SQL query isn't performing as well as it could and I could need some advice on how to change my Linq To SQL query to make it more efficient. The tables that are used Product contains a unique id for each product. Thi...

Compiler optimizations: Where/how can I get a feel for what the payoff is for different optimizations?

In my independent study of various compiler books and web sites, I am learning about many different ways that a compiler can optimize the code that is being compiled, but I am having trouble figuring out how much of a benefit each optimization will tend to give. How do most compiler writers go about deciding which optimizations to imple...

Russian Peasant Multiplication

Here is my short implementation of Russian Peasant Multiplication. How can it be improved? Restrictions : only works when a>0,b>0 for(p=0;p+=(a&1)*b,a!=1;a>>=1,b<<=1); ...

What are the optimal settings for Tomcat web server?

I am maintaining a website with currently about 800 concurrent users. The business plan says that this number will be 10x higher in one year. This is my current configuration: <Connector port="8080" address="${jboss.bind.address}" maxThreads="500" maxHttpHeaderSize="8192" emptySessionPath="true" protocol="HTTP/1.1" enableLookups=...

C++: Best algorithm to check if a vector is sorted

What would be the best way to check that a std::vector is sorted ? Is there something faster than a loop checking that v[i]<=v[i+1] ? Is it faster/cleaner with iterators ? Or is it actually better to just call sort every time (though the "v is already sorted" case is quite common) ? We can safely assume the vector only contains PODs, us...

What overhead is there of using an MXML file in Flex vs. a plain actionscript class?

I find it much easier to write MXML classes with embedded Script than trying to make an actionscript file. I was wondering however what kind of overhead there is of using an MXML file - in terms of file size. I'm not especially concerned about performance, but if that is relevant would be interested in any findings. Obviously I'm talki...

One could use a profiler, but why not just halt the program?

If something is making a single-thread program take, say, 10 times as long as it should, you could run a profiler on it. You could also just halt it with a "pause" button, and you'll see exactly what it's doing. Even if it's only 10% slower than it should be, if you halt it more times, before long you'll see it repeatedly doing the unnec...

Why are C++ methods sometimes defined inside classes?

I frequently run into large, non-template classes in C++ where simple methods are defined directly in the class body in the header file instead of separately in the implementation file. For example: class Foo { int getBar() const { return bar; } ... }; Why do this? It seems like there are disadvantages. The implementation is not a...

Better performance on updating objects with linq

I have two lists of custom objects and want to update a field for all objects in one list if there is an object in the other list which matches on another pair of fields. This code explains the problem better and produces the results I want. However for larger lists 20k, and a 20k list with matching objects, this takes a considerable ti...

What are some tricks that a processor does to optimize code?

I am looking for things like reordering of code that could even break the code in the case of a multiple processor. ...

String operation optimisation in C#

The following C# code takes 5 minutes to run: int i = 1; string fraction = ""; while (fraction.Length < 1000000) { fraction += i.ToString(); i++; } "Optimising it" like this causes it to run in 1.5 seconds: int i = 1; string fraction = ""; while (fraction.Length < 1000000) { // concatenating strings is much faster for sma...

C++ compiler optimization of passed arguments

I'm using a logging module that can have reporting enabled/disabled at runtime. Calls generally go something like: WARN( "Danger Will Robinson! There are " + boost::lexical_cast<string>(minutes) + " minutes of oxygen left!" ); I'm using an inline function for WARN, but I'm curious as to how much optimization is going on...

Time complexity of memory allocation

What is the time complexity of dynamic memory allocation using new, malloc, etc.? I know very little about how memory allocators are implemented, but I assume the answer is that it depends on the implementation. Therefore, please answer for some of the more common cases/implementations. Edit: I vaguely remember hearing that heap allo...

Freeing alloca-allocated memory

Is it possible to free memory allocated by C's alloca() explicitly, before the current function exits? If so,how? ...

Emulate old PC?

I'm writing a Flash game, pretty intensive on CPU. Besides optimizing it a lot, I would like to be able to play it as players on slow PC's will, because I have a good CPU and I would like to make it also playable on bad CPU's First I thought that virtualization would help, but I've tried vmware player with an ubunto image and I can't f...

How to synchronize C & C++ libraries with minimal performance penalty?

I have a C library with numerous math routines for dealing with vectors, matrices, quaternions and so on. It needs to remain in C because I often use it for embedded work and as a Lua extension. In addition, I have C++ class wrappers to allow for more convenient object management and operator overloading for math operations using the C A...