efficiency

VB.net Memory efficient function needed

Hi All, I'm getting out of memory exceptions from the following function when RowCollection is 50000+ and thus i need to make it more memory efficient. The function is simply needs to construct a comma separated string of the row indexes stored in RowCollection. Can anyone spot any obvious memory hungry operations in the following? N....

Efficient insertion/deletion algorithm for an array

Hi there, I subscribe to a data feed and from that create and maintain a structure using the index values on the INSERT/DELETE messages. I would like to ask the assembled cognoscenti whether they know of any algorithm which can deal with the piecemeal updates in an efficient way - generally batch-updates contain between two and six suc...

Efficient Hex Manipulation

I have a byte array represented by hex values, these are time durations. The data could be converted to integer values and multiplied by a constant to get the timings. The decoding of the data will be saved to a file as a series of hex strings. What would be an efficient way of manipulating hex values? I was looking at performance iss...

Efficient structure for Multiple Thread access

I need to implement a mechanism which has a datastruture (Queue at this moment) that contains a list of pending request objects which are marked by different threads when being used and taken off when a thread is finished using it. This datastructure could have up to a few thousand items in it at any given time and N threads will be t...

Return a value or modify reference?

I've seen both before, and as far as I know, it's pretty much subjective, but if given the option, which would you do and why? If the data were large, would there be any speed/memory benefit to one of them? function processData(&$data_to_process) { // Pass by reference. // do something to the data } // ... somewhere else $this->p...

MySQL: how should I draft this database?

I'm designing a plugin for a high traffic forum. What I am doing is listing related threads using a search API, which has a maximum of 800 searches per day What I'm wanting to do is create a database to store the results, cache them for one day so it will be used instead of the API. Would a table layout such as this be optimal: Tabl...

Efficient way to divide a String

Hello, I have a String which can be very long so I want to split it in an array of Strings so in each position the string's length should be lower than a specified number. The split can only be done in a white space or after a punctuation symbol, because I need that each fragments makes sense when it is read. It is something like a word...

efficient longest common subsequence algorithm library?

I'm looking for a (space) efficient implementation of an LCS algorithm for use in a C++ program. Inputs are two random access sequences of integers. I'm currently using the dynamic programming approach from the wikipedia page about LCS. However, that has O(mn) behaviour in memory and time and dies on me with out of memory errors for larg...

How to KISS and smart this method

I have an action in my RoR application, and it calls a different script depending on the user running it. def index @user = User.find(session[:user_id], :include => [ :balances, :links, :comments ]) render :file => "#{RAILS_ROOT}/app/views/user/index_#{@user.class.to_s.downcase}.html.erb" end How to make the call to render a m...

For which kind of applications can the Garbage Collector become a concern?

Because of their efficiency, most of the Garbage Collector algorithm are inoffensive in a lot of applications. The "collection" of objects does however require a small overhead cost in order to scan the stack and to liberate non referenced object from the heap. I know one part of the answer is "it depends". However, I would like to kno...

How Can i optimize qTip?

Hey everyone! i've been doing some profiling on an app i'm working on and qTip is really slowing it down! I love this plugin but adding the tips on document ready is taking almost 2 whole seconds (about 300 tips on the page). I know it's a lot of tips, but is there anyway obvious or not so obvious ways to speed this up? i'm using th...

C# - Multiple Text Box Non-Zero Length Validation Efficiency

Hi all, I've got six text boxes, and as long as one has valid input in it I want my program to go ahead with import code. Problem is I don't know what the most efficient way to do it is. The two alternatives I've come up with thus far are as follows: Version 1: //if no paths are specified the user is shown an error and the prog...

PHP: Efficient way to store simple cache array in database?

Basically for a plugin for a dynamic site (site can be fairly large) I am caching results of some sort of search (because results are from an external search), the results can be 400-1500 characters in length. As the results come in an array, I use json_encode (faster than serialize) to store in the database, but ~1.5KB per entry (since...

Efficient polynomial evaluation with Horner's Algorithm

I have the equation y = 3(x+1)^2 + 5(x+1)^4. Using Horner's scheme I could evaluate this polynomial in this form, y = 8+x(26+x(33+x(20+5x))), thus requiring 8 arithmetic operations. I could also evaluate it in this form, y = (x+1)^2 * ((5x+10)x+8), requiring 7 operations. I've been told this can be done in 5 operations but Horner's a...

Duplicating records efficiently in tsql

Hey guys, I've a scenario where I have a parent table which has '1 to many' relationships with two or three tables. These child tables again have '1 to many' relationships with more tables and so on. This goes up to 5 to 6 levels of hierarchy. Now, based on single primary key value of the parent table, I want to duplicate all informati...

MySQL - Select un-matching data in a one to many relationship

Hi All, First of all, this question is in regards to PHP and MySQL I have two database tables: The People table: person_id | field_1 | field_2 | other_fields... And the Notes table: note_id | person_id | created_timestamp | other_fields... The People table has a one to many relationship with the Notes table... E...

Search in a sorted array of ints which rolls over

Is there a easy way to search in an array like this? Some examples below : 5 6 7 8 19 45 21 32 40 // Rolled over at 7 th element 15 22 32 45 121 341 40 // Rolled over at 7 th element 1 22 32 45 121 341 400 // Rolled over at 0 th element ...

How to improve the transfer-code-from-mind-to-file effort?

QUESTION OBSOLETE: This question has been re-asked, in a much more condensed form, on programmers.stackexchange. Please vote to have this question closed. Programmers' trade is essentially to write code. Yes, there is a lot more involved than that, but when you really boil down to it, at the end of the day, programmers will have produce...

Foreaching through grouped linq results is incredibly slow, any tips?

I did some profiling on a program that I'm running and the thing that takes the longest time is getting the results from the linq query: var Results = from a in Table group a by a.Value into b select new {Group = b}; foreach(var Result in Results) { //Do calcs } Any ideas on how I can speed this up? ...

Most Efficient way to 'look up' Keywords

Alright so I am writing a function as part of a lexical analyzer that 'looks up' or searches for a match with a keyword. My lexer catches all the obvious tokens such as single and multi character operators (+ - * / > < = == etc) (also comments and whitespace are already taken out) so I call a function after I've collected a stream of onl...