running-time

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); }...

In SQL, How does using DISTINCT affect performance?

I am attempting to select a distinct list where duplicates are created over several fields. For example, SELECT tablename.field1Date, tablename.field2Number, tablename.field3Text FROM tablename; Would select duplicating records over the date, number and text fields respectively. Now, when I select distinct records t...

Optmizing MySQL GROUP BY or DISTINCT on large views

Consider a view consisting of several tables... for example a v_active_car, which is made up of the tables car joined on to body, engine, wheels and stereo. It might look something like this: v_active_cars view SELECT * FROM car INNER JOIN body ON car.body = body.body_id INNER JOIN engine ON car.engine = engine.engine_id I...

Biggest performance improvement you've had with the smallest change?

What's the biggest performance improvement you've had with the smallest change? For example, I once improved the performance of a certain page on a high-profile web app by a factor of 10, just by moving "where customerID = ?" to a different place inside a complicated SQL statement (before my change it had been selecting all customers in...

Unix Command For Benchmarking Code Running K times

Hi, Suppose I have a code executed in Unix this way: $ ./mycode My question is is there a way I can time the running time of my code executed K times. The value of K = 1000 for example. I am aware of Unix "time" command, but that only executed 1 instance. ...

When is assembler faster than C?

One of the stated reasons for knowing assembler is that, on occasion, it can be employed to write code that will be more performant than writing that code in a higher-level language, C in particular. However, I've also heard it stated many times that although that's not entirely false, the cases where assembler can actually be used to g...

Run application continuously

Whats the smartest way to run an application continuously so that it doesn't exit after it hits the bottom? Instead it starts again from the top of main and only exits when commanded. (This is in C) ...

Hibernate Query runs slow in the system, but fast when run directly.

I have a problem similar to the on in this weeks podcast. We have a Java application using hibernate with Sql Server 2005. Hibernate is generating a Query for us that is taking nearly 20 minutes to complete. If we take the same query using show_sql and replace the questions marks with constant value the answer is returned immediately....

What is the relation between merges and number of items in a in k-way merge

The question is: In a k-way merge, how many merge operation will we perform. For example: 2-way merge:2 nodes 1 merge; 3 nodes 2 merge; 4 nodes 3 merge. So we get M(n)=n-1. What the the M(n) when k is arbitrary? ...

Understanding Ruby on Rails render times

I am working on an "optimization" on my application and I am trying to understand the output that rails (version 2.2.2) gives at the end of the render. Here is the "old" way: Rendered user/_old_log (25.7ms) Completed in 466ms (View: 195, DB: 8) | 200 OK And the "new" way: Rendered user/_new_log (48.6ms) Completed in 337ms (View: 192...

Why do my ASP.NET pages render slowly when placed on the server?

I have a simple aspx page with a GridView control. I'm loading the GridView with search results after the click of a button. Everything works, but the HTML rendering on the browser is very slow in IE with a result set > 2000 (works fine in other browsers.) I realize it's slow due to the record count, but is there a way I can make it fas...

Runtime optimization of static languages: JIT for C++?

Is anyone using JIT tricks to improve the runtime performance of statically compiled languages such as C++? It seems like hotspot analysis and branch prediction based on observations made during runtime could improve the performance of any code, but maybe there's some fundamental strategic reason why making such observations and impleme...

c++ optimization

I'm working on some existing c++ code that appears to be written poorly, and is very frequently called. I'm wondering if I should spend time changing it, or if the compiler is already optimizing the problem away. I'm using Visual Studio 2008. Here is an example: void someDrawingFunction(....) { GetContext().DrawSomething(...); Ge...

Fastest function to generate Excel column letters in C#

What is the fastest c# function that takes and int and returns a string containing a letter or letters for use in an Excel function? For example, 1 returns "A", 26 returns "Z", 27 returns "AA", etc. This is called tens of thousands of times and is taking 25% of the time needed to generate a large spreadsheet with many formulas. p...

How can I improve this square root method?

I know this sounds like a homework assignment, but it isn't. Lately I've been interested in algorithms used to perform certain mathematical operations, such as sine, square root, etc. At the moment, I'm trying to write the Babylonian method of computing square roots in C#. So far, I have this: public static double SquareRoot(double x) ...

Performance optimization strategies of last resort?

There are plenty of performance questions on this site already, but it occurs to me that almost all are very problem-specific and fairly narrow. And almost all repeat the advice to avoid premature optimization. Let's assume: the code already is working correctly the algorithms chosen are already optimal for the circumstances of the pr...

How to model execution time of algorithms?

Which models of algorithm running time exist? We all expect mergesort to be faster than bublesort, and note that mergesort makes O(n log n) comparisons vs. O(n2) for bubblesort. For other algorithms, you count other operations (than compares and swaps), such as pointer dereference, array lookup, arithmetic on fixed-size integers, etc. ...

A min-heap with better than O(logn) increase key?

I'm using a priority queue that initially bases the priority of its elements on a heuristic. As elements are dequeued the heuristic is updated and elements currently in the queue may have their keys increased. I know there are heaps (Fibonacci heaps specifically) that have amortized O(1) decrease key operations, but are there any heap ...

Will optimizing code become unnecessary?

If Moore's Law holds true, and CPUs/GPUs become increasingly fast, will software (and, by association, you software developers) still push the boundaries to the extent that you still need to optimize your code? Or will a naive factorial solution be good enough for your code (etc)? ...

Algorithms for Optimization with Fast Disk Storage (SSDs)?

Given that Solid State Disks (SSDs) are decreasing in price and soon will become more prevalent as system drives, and given that their access rates are significantly higher than rotating magnetic media, what standard algorithms will gain in performance from the use of SSDs for local storage? For example, the high random read speed of SS...