performance

Why is Enumerable.Range faster than a direct yield loop?

The code below is checking performance of three different ways to do same solution. public static void Main(string[] args) { // for loop { Stopwatch sw = Stopwatch.StartNew(); int accumulator = 0; for (int i = 1; i <= 100000000; ++i) { accumulator +...

JPA/Hibernate query optimization with null values

I'm using Hibernate's implementation of JPA and am seeing poor performance as multiple SQL queries are issued for each entity that is fetched. If I use a joined JPA query it generates just one SQL query but doesn't find rows will null relationship. Example, consider this simple schema. A person lives at an address and is employed by a c...

Is String.IndexOf(char) really slower than manual searching?!

When doing a simple performance measurement, I was astonished to see that calling String.IndexOf(char) was actually slower than doing it manually! Is this really true?! Here is my test code: const string str = @"91023m lkajsdfl;jkasdf;piou-09324\\adf \asdf\45\ 65u\ 86\ 8\\\;"; static int testIndexOf() { return str.IndexOf('\\'); } stati...

Why is ActiveRecord issuing a separate query per join?

I'm doing an ActiveRecord find operation (via the "will_paginate" library) like this: contacts = Contact.paginate(:all, :conditions => conditions_specified, :select => "DISTINCT contacts.*", :joins => joins, :include => [:addresses, :emails, :phone_numbers, {:addresses => :organization}], :page => page, :per_pa...

Avoiding array duplication

According to MSDN: Array usage guidelines: Array Valued Properties You should use collections to avoid code inefficiencies. In the following code example, each call to the myObj property creates a copy of the array. As a result, 2n+1 copies of the array will be created in the following loop. [Visual Basic] Dim i As Integer For i...

Optimization techniques for large databases

What optimization techniques do you use on extremely large databases? If our estimations are correct, our application will have billions of records stored in the db (MS SQL Server 2005), mostly logs that will be used for statistics. The data contains numbers (mostly integer) and text (error message texts, URLs) alike. I am interested in...

Is there a difference in term of performance between "unsigned int" and "int" on the IPhone?

Or to reformulate the question: is there a performance penalty in using unsigned values? And in general: what is the most performant type (16bit signed?, 32bit signed? etc.) on the IPhone ARM processor? ...

How do you not do joins?

I've been reading a lot lately about how joins in DB queries slow things down. Evidently Google App Engine doesn't even allow them. I'm wondering how people design an app with no joins though. For example I'm working on an app that has contacts and organizations. A contact can be in many organizations and an organization can have many c...

How to ignore login and logout requests in JMeter?

I'm trying to test the performance of our webapp with JMeter. The login procedure includes some external dependencies that can't be reproduced during the test, so I've programmed an alternate login. As this alternate login request is not part of the normal workflow I would like to exclude the login request from the JMeter results because...

Are there performance benefits when upgrading SQL2000 to SQL2005?

I've had a look at this question but there are no responses regarding performance. Are there any performance benefits from doing a simple upgrade from SQL2000 to SQL2005? I am thinking a line of business OLTP datbase. I am not using OLAP or FTI. ...

Caching database data in Session - getting the balance right

If you cache data from your database in ASP.NET Session then you will speed up subsequent requests for that data (note: depending on the serialization/deserialization cost of the data concerned), at the expense of memory load in IIS. (OK, this is probably a simplification of the reality of the situaiton - feel free to correct or refine ...

Swing Large Files Performance

Hello, We need to load and display large files (rich text) using swing, about 50mb. The problem is that the performance to render the files is incredibly poor. We tried both JTextPane and JEditorPane with no luck. Does someone have experience with this and could give me some advise ? thanks, ...

Performance of Dynamic SQL with Bind vs Normal SQL within Package

In an Oracle 10g environment, I have a statement that needs to be executed several million times based on the results of a cursor. For flexibility, the current code has the statement as a constant in the package body. Here is a simplified version of the code. Please keep in mind this is all within the same package: c_Stmt CONSTANT VARC...

Linq vs. database views

Here’s an interesting question. Suppose we have related tables in the database, for example, Instrument and Currency. Instrument table has a currency_id field that is mapped to entry in Currency table. In Linq land what’s the better way: a) Create Instrument and Currency entities in the DataContext and then create association or simply ...

Any way to further optimize Java reflective method invocation ?

I am wondering if there are any additional optimizations I can implement to improve the speed of reflective invocations in Java. Not that the performance is prohibitive, but I get the willies when thinking about some piece of code in a library I am writing being implemented in a tight loop somewhere. Consider a utility method to invoke ...

Are there any tools to optimize the number of consumer and producer threads on a JMS queue?

I'm working on an application that is distributed over two JBoss instances and that produces/consumes JMS messages on several JMS queues. When we configured the application we had to determine which threading model we would use, in particular the number of producing and consuming threads per queue. We have done this in a rather ad-hoc f...

[.NET] Should I roll my own version of ParseInt32?

I am writing a high performance parser, and it seems to me that Int32.Parse can be too slow. I wrote a simple version that assumes correct input, and it's performing much better. So should I create my own version instead? Or is there another faster method already available? My method is like this: // parse simple int, assuming relative...

Performance of HttpWebRequest using POST

I have a small tool I use for testing a webservice. It can either call the webservice using POST or using GET. The code for using POST is public void PerformRequest() { WebRequest webRequest = WebRequest.Create(_uri); webRequest.ContentType = "application/ocsp-request"; webRequest.Method = "POST"; webRequest.Credentials = _cr...

.NET Attributes: Why does GetCustomAttributes() make a new attribute instance every time?

So I was playing around a little more with attributes in .NET, and realized that every call to Type.GetCustomAttributes() creates a new instance of my attribute. Why is that? I would think that the attribute instance would basically be a singleton-per-MemberInfo, with 1 instance bound to the Type, PropertyInfo, etc... Here is my test co...

How Do I Track and Eliminate Session Abuse?

I'm pretty sure that there have been developers in the past that have severely abused our poor friend ASP.NET session state. Session would love to help track things between requests, but can only do so much! Please help me ease its pain so that it can work with us happily ever after. Does anyone know of a tool that can monitor session...