performance

When does reflow happen in a DOM environment?

What kinds of activities will trigger reflow of web page with DOM? It seems there are different points of view. According to http://www.nczonline.net/blog/2009/02/03/speed-up-your-javascript-part-4/, it happens When you add or remove a DOM node. When you apply a style dynamically (such as element.style.width="10px"). When you retriev...

why is UDF so much slower than subquery

I have a case where i need to translate (lookup) several values from the same table. First way I wrote it, was using subqueries: SELECT (SELECT id FROM user WHERE user_pk = created_by) AS creator, (SELECT id FROM user WHERE user_pk = updated_by) AS updater, (SELECT id FROM user WHERE user_pk = owned_by) AS owner, [name] FRO...

What is the most efficient way to Deserialze an XML file

Aloha, I have a 8MB XML file that I wish to deserialize. I'm using this code: public static T Deserialize<T>(string xml) { TextReader reader = new StringReader(xml); Type type = typeof(T); XmlSerializer serializer = new XmlSerializer(type); T obj = (T)serializer.Deserialize(reader); return obj; } This code runs...

.Net Static Methods and it's effects on Concurrency ?

I am currently building an API which will be used by a webservice. I was wondering what performance issues I could meet if I built my API using a large amount of static methods. The original idea was to build expert objects which act as services. In a single user environment this approach was great! But I will soon need to port this...

mySQL large text comparisson performance... best practices?

I've got a largish (~1.5M records) table that holds text strings of varying length for which I run queries against looking for matches: CREATE TABLE IF NOT EXISTS `shingles` ( `id` bigint(20) NOT NULL auto_increment, `TS` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `shingle` varchar(255) NOT NULL, `...

Best way to measure execution time in automated regression tests

I have some code that I want to measure the speed of while it runs continuously in automated regression tests. The purpose of this would be to alert me to changes made to the code which have had a negative impact on performance. In pseudo-code, I want something like this: cpuTimer.start runTest cpuTimer.stop diff = cpuTimer.getDuratio...

"SELECT COUNT(*)" is slow, even with where clause

I'm trying to figure out how to optimize a very slow query in MySQL (I didn't design this): SELECT COUNT(*) FROM change_event me WHERE change_event_id > '1212281603783391'; +----------+ | COUNT(*) | +----------+ | 3224022 | +----------+ 1 row in set (1 min 0.16 sec) Comparing that to a full count: select count(*) from change_event; ...

PHP landmines in general

What surprises have other people found with writing PHP web applications? There's the well known and to be fixed issue with compile time class inheritance but I know of a couple others and wanted to try and build a list of the top gotcha's of the language. Note: I've held several positions as a Sr. PHP5 developer so PHP work pays my ...

SQL Performance Question

Hi, I have a question regarding the performance of SQL. I will illustrate my problem with pseudocode. I am wondering which will preform better and by how much? Say for 10 items, on each page load. In .NET. Is is a lot faster? a little faster? A difference not noticable on SQL? foreach(item in mylist) { CallSQLStoredProc(item.id); }...

What's the fastest way for a true sinatra(ruby/rack) after_filter?

Okay it's a simple task. After I render html to the client I want to execute a db call with information from the request. I am using sinatra because it's a lightweight microframework, but really i up for anything in ruby, if it's faster/easier(Rack?). I just want to get the url and redirect the client somewhere else based on the url...

Should I use Java's String.format() if performance is important?

We have to build Strings all the time for log output and so on. Over the JDK versions we have learned when to use StringBuffer (many appends, thread safe) and StringBuilder (many appends, non-thread-safe). What's the advice on using String.format? Is it efficient, or are we forced to stick with concatenation for one-liners where perform...

How long does a context switch take in Linux?

I'm curious how many cycles it takes to change contexts in Linux. I'm specifically using an E5405 Xeon (x64), but I'd love to see how it compares to other platforms as well. ...

Templatized branchless int max/min function

I'm trying to write a branchless function to return the MAX or MIN of two integers without resorting to if (or ?:). Using the usual technique I can do this easily enough for a given word size: inline int32 imax( int32 a, int32 b ) { // signed for arithmetic shift int32 mask = a - b; // mask < 0 means MSB is 1. return a +...

What are the ways to find bottlenecks in a web application?

How do I benchmark the performance of my web applications? Is there a way to find out the bottlenecks in a web application? EDIT: I am not asking about any front end tweaks like images, css etc. What I want to know is how to profile the back end of the application so that I will know which methods/queries to modify to increase the perf...

Speed: Java serialization or csv?

I have a large array of Java simple structs (consists of just primitive members) and I need to save and load them from and to a file What would be faster, implementing java.io.Serializable and using read/writeObject or overriding toString() / toCSV(), adding a new constructor and reading/writing to text file? I want to avoid b...

Question about GetHashCode implementation

http://msdn.microsoft.com/en-us/library/system.object.gethashcode(VS.80).aspx says: For the best performance, a hash function must generate a random distribution for all input. Does it have any effect in performance or it's ok to use a function (like return this.Id) that doesn't give a "random distribution" but it doesn't cause mor...

IE6 performance with CSS expressions

We are developing a web application that will be sold to many clients. There is already one client (a bank) which has decided that it will buy the product once it is ready. Unfortunately due to some miscommunication it came out rather late that the only browser they use is IE6. The application was already started with the thought in mind...

How to benchmark virtual machines

I am trying to perform a fair comparison of XenServer vs ESX and one comparison I would like to make is performance with multiple VMs. Does anyone know how to go about benchmarking VM performance in a fair way? On each server I would like to run a fixed number of XP/Vista VMs (for example 8) and have some measure of how quickly each one...

How to speed up a web site where most page resources are already cached by the browser

I want to improve the page load times of a web site. It is a web application (think something like web mail) with relatively few users that spend long periods using the site. As almost all page requests are from users that have already used the site, images, css and external javascript resources will have been cached by the browser dur...

In terms of performance, which is better Flex or Silverlight?

In general, which performs better? How are they like when processing vector graphics? ...