efficiency

What does your team do to stand out?

Where I work, we have small teams of 2 - 5 people. As a dev lead, what are some things that you've implemented which makes your team stand out from the others? Meaning, it makes the others teams say, "that's cool" or "why didn't we think of that". Just some thinking out of the box that made your team extremely efficient. ...

List of strings to one string

Lets say you have a: List<string> los = new List<string>(); In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these: String.Join(String.Empty, los.ToArray()); StringBuilder builder = new StringBuilder(); los.ForEach(s => builder.Append(s)); string disp = l...

#inject and slowness

I've often heard Ruby's inject method criticized as being "slow." As I rather like the function, and see equivalents in other languages, I'm curious if it's merely Ruby's implementation of the method that's slow, or if it is inherently a slow way to do things (e.g. should be avoided for non-small collections)? ...

How Does AQTime Do It?

I've been testing out the performance and memory profiler AQTime to see if it's worthwhile spending those big $$$ for it for my Delphi application. What amazes me is how it can give you source line level performance tracing (which includes the number of times each line was executed and the amount of time that line took) without modifyi...

Best way to check for current date in where clause of sql query.

I'm trying to find out the most efficient (best performance) way to check date field for current date. Currently we are using: SELECT COUNT(Job) AS Jobs FROM dbo.Job WHERE (Received BETWEEN DATEADD(d, DATEDIFF(d, 0, GETDATE()), 0) AND DATEADD(d, DATEDIFF(d, 0, GETDATE()), 1)) ...

What is the most efficient way to manage a large set of lines in OpenGL?

I am working on a simple CAD program which uses OpenGL to handle on-screen rendering. Every shape drawn on the screen is constructed entirely out of simple line segments, so even a simple drawing ends up processing thousands of individual lines. What is the best way to communicate changes in this collection of lines between my applicati...

Simple efficiency question C++ (memory allocation)..and maybe some collision detection help?

I'm writing a little arcade-like game in C++ (a multidirectional 2d space shooter) and I'm finishing up the collision detection part. Here's how I organized it (I just made it up so it might be a shitty system): Every ship is composed of circular components - the amount of components in each ship is sort of arbitrary (more components, ...

How can I find the Largest Common Substring between two strings in PHP?

Is there a fast algorithm for finding the Largest Common Substring in two strings or is it an NPComplete problem? In PHP, I can find a needle in a haystack: <?php if (strstr("there is a needle in a haystack", "needle")) { echo "found<br>\n"; } ?> I guess I could do this in a loop over one of the strings but that would be very ex...

Is there a more efficient way of creating a list of years/months?

On a page I want to dynamically list years and all the months in each year so an archive for each month can be viewed. I want to show the current year first but the current year may not be over yet so I only want to show the months that have passed, and the current month. Then I want all years and all months in the past since this year (...

Generating an XML file from a script

I've recently have a reason to include into our build script the creation of an XML configuration file. The most straightforward way I can think of to do this is to hard-code the XML content as a string into the script and then to simply create a file and write that XML string to the file (named appropriately etc). Is there a more elegan...

Make C# algorithm more efficient

I have a C# method that projects the value of a number from an interval to a target interval. For example: we have an interval of -1000 and 9000 and a value of 5000; if we want to project this value to an interval of 0..100 we get 60. Here is the method: /// <summary> /// Projects a value to an interval /// </summary> /// <param nam...

Efficient algorithm for comparing XML nodes

Hi, I want to determine whether to different child nodes within an XML document are equal or not. Two nodes should be considered equal if they have the same set of attributes and child notes and all child notes are equal, too (i.e. the whole sub tree should be equal). The input document might be very large (up to 60MB, more than a 1000...

What is the most efficient way of extracting information from a large number of xml files in python?

Hi, I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. I...

Efficient Methods for a Life Simulation

Having read up on quite a few articles on Artificial Life (A subject I find very interesting) along with several questions right here on SO, I've begun to toy with the idea of designing a (Very, very, very) simple simulator. No graphics required, even. If I've overlooked a question, please feel free to point it out to me. Like I said, t...

Fastest javascript page search

I am writing a Firefox extension. I would like to search the current webpage for a set of words, and count how many times each occurs. This activity is only performed when the user asks, but it must still happen reasonably quickly. I am currently using indexOf on the BODY tag's innerHTML element, but am finding it too slow to run repeat...

Help me use MKS Integrity (source code control) more efficiently

We use MKS Integrity for our source control. I have no control over that -- I just have to use it. What are some "gotchas" that I should know about and avoid? And, are there any neat things about the software that will allow me to use it better? I've already hit cases where the tree structure in the source control doesn't match tha...

Problems storing numeric data in text columns - SELECT...BETWEEN

A few years ago I worked on a system where a numeric primary key was stored in a [SQL Server] varchar column, so I quickly came unstuck when querying with a BETWEEN operator: SELECT ID FROM MyTable WHERE ID BETWEEN 100 AND 110; Results: 100 102 103 109 110 11 This was simply bad design. However, I'm working on an 3rd-party ERP syst...

Excel Interop - Efficiency and performance

I was wondering what I could do to improve the performance of Excel automation, as it can be quite slow if you have a lot going on in the worksheet... Here's a few I found myself: ExcelApp.ScreenUpdating = false -- turn off the redrawing of the screen ExcelApp.Calculation = Excel.XlCalculation.xlCalculationManual -- turning off the ca...

Fastest way to move files on a Windows System

I want to move about 800gb of data from an NTFS storage device to a FAT32 device (both are external hard drives), on a Windows System. What is the best way to achieve this? Simply using cut-paste? Using the command prompt ? (move) Writing a batch file to copy a small chunks of data on a given interval ? Use some specific application t...

What Simple Changes Made the Biggest Improvements to Your Delphi Programs

I have a Delphi 2009 program that handles a lot of data and needs to be as fast as possible and not use too much memory. What small simple changes have you made to your Delphi code that had the biggest impact on the performance of you program by noticeably reducing execution time or memory use? Thanks everyone for all your answers. M...