optimization

Process vs Threads

How to decide whether to use threads or create seprate process altogether in your application to achieve parallelism. ...

Refactoring dissassembled code

You write a function and, looking at the resulting assembly, you see it can be improved. You would like to keep the function you wrote, for readability, but you would like to substitute your own assembly for the compiler's. Is there any way to establish a relationship between your high-livel language function and the new assembly? ...

Why to use StringBuffer in Java instead of the string concatenation operator

Someone told me it's more efficient to use StringBuffer to concatenate strings in Java than to use the + operator for Strings. What happens under the hood when you do that? What does StringBuffer do differently? ...

faster Math.exp() via JNI?

Hi, I need to calculate Math.exp() from java very frequently, is it possible to get a native version to run faster than java's Math.exp()?? I tried just jni + C, but it's slower than just plain java. ...

Are there any advantages compiling for .NET Framework 3.5 instead of 2.0?

Are there any advantages compiling for .NET Framework 3.5 instead of 2.0? For example less memory consumption, faster startup, better performance... Personally I don't think so however, I may have missed something. Edit: Of course there are more features in the 3.5 framework, but these are not the focus of this question. Edit2: There...

Does Java save its runtime optimizations?

My professor did an informal benchmark on a little program and the Java times were: 1.7 seconds for the first run, and 0.8 seconds for the runs thereafter. Is this due entirely to the loading of the runtime environment into the operating environment or is it influenced by Java's optimizing the code and storing the results of those optim...

char[] to hex string exercise

Below is my current char* to hex string function. I wrote it as an exercise in bit manipulation. It takes ~7ms on a AMD Athlon MP 2800+ to hexify a 10 million byte array. Is there any trick or other way that I am missing? How can I make this faster? Compiled with -O3 in g++ static const char _hex2asciiU_value[256][2] = { {'0','0'...

What is your favorite low-level profiling tool?

Its not uncommon that I have a program whose performance relies heavily on just a few functions and I want to be able to measure a single loop or code segment's speed down to single-clock precision so that I know whether my changes are actually improving performance or whether I'm just falling for the placebo of "optimized" code. I pers...

Good way to time SQL queries when using Linq to SQL

Is there a good way to time SQL queries when using Linq to SQL? I really like logging feature, but it would be great if you could somehow also time that query. Any ideas? ...

Spatial Data Structures in C

I do work in theoretical chemistry on a high performance cluster, often involving molecular dynamics simulations. One of the problems my work addresses involves a static field of N-dimensional (typically N = 2-5) hyper-spheres, that a test particle may collide with. I'm looking to optimize (read: overhaul) the the data structure I use ...

What is the fastest way to convert float to int on x86

What is the fastest way you know to convert a floating-point number to an int on an x86 CPU. Preferrably in C or assembly (that can be in-lined in C) for any combination of the following: 32/64/80-bit float -> 32/64-bit integer I'm looking for some technique that is faster than to just let the compiler do it. ...

Does use of anonymous functions affect performance?

I've been wondering, is there a performance difference between using named functions and anonymous functions in Javascript? for (var i = 0; i < 1000; ++i) { myObjects[i].onMyEvent = function() { // do something }; } vs function myEventHandler() { // do something } for (var i = 0; i < 1000; ++i) { myObjects[i...

Runtime Page Optimizer for ASP.net - Any comments?

RPO 1.0 (Runtime Page Optimizer) is a recently (today?) released component for ASP and Sharepoint that compresses, combines and minifies (I can’t believe that is a real word) Javascript, CSS and other things. What is interesting is that it was developed for ActionThis.com a NZ shop that saw at TechEd last year. They built a site that q...

Most efficient way to increment a Map value in Java

I hope this question is not considered too basic for this forum, but we'll see. I'm wondering how to refactor some code for better performance that is getting run a bunch of times. Say I'm creating a word frequency list, using a Map (probably a HashMap), where each key is a String with the word that's being counted and the value is an I...

Help with algorithm for merging vectors

I need a very fast algorithm for the following task. I have already implemented several algorithms that complete it, but they're all too slow for the performance I need. It should be fast enough that the algorithm can be run at least 100,000 times a second on a modern CPU. It will be implemented in C++. I am working with spans/ranges, a...

How can you get database specific performance metrics for things like CPU/Memory/etc. in SQL Server 2005?

I have a couple databases on a shared SQL Server 2005 cluster instance, that I would like performance metrics on. I have some processes that run for a very long time and suspect that code inefficiencies, rather than insufficient hardware are to blame. I would like some way to get these performance metrics so that I can rule out the data...

How to optimize an application to make it faster?

I have created an application executable, it works, but it runs too slow, a lot slower than needed. I would like to make it faster. What can I do to optimize it? ...

What is the cost of a function call?

Compared to Simple memory access Disk access Memory access on another computer(on the same network) Disk access on another computer(on the same network) in C++ on windows. ...

Practical limit to length of SQL query (specifically MySQL)

Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses? For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this program to generate: SELECT * FROM 4e_magic_items INNER JOIN 4e_magic_item_lev...

STL vectors with uninitialized storage?

I'm writing an inner loop that needs to place structs in contiguous storage. I don't know how many of these structs there will be ahead of time. My problem is that STL's vector initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the cost of setting the struct's members to their values. Is t...