efficiency

How do I Copy the Values of an IDictionary into an IList Object in .Net 2.0?

If I have a: Dictionary<string, int> How do I copy all the values into a: List<int> Object? The solution needs to be something compatible with the 2.0 CLR version, and C# 2.0 - and I really dont have a better idea, other than to loop through the dictionary and add the values into the List object one-by-one. But this feels very in...

How can I make Emacs start-up faster?

I use Emacs v. 22 (the console version, either remotely with PuTTY or locally with Konsole) as my primary text editor on Linux. It takes a while to load up each time I start it though, probably almost a second, although I never timed it. I tend to open and close Emacs a lot, because I'm more comfortable using the Bash command-line for fi...

Penalties of a script constantly looping in the background

I know this topic has been discussed in the past, but I am a tiny bit paranoid about resource usage. I am looking into writing a daemon for queing jobs to archive files into zip files for a web app i am working on. It would behave something like this: while True: while morejobs(): zipfile() sleep(15seconds) What sort ...

Efficient cloning of cached objects

We have an application that performs comparisons on data objects to determine if one version of the object is different than another. Our application also does some extensive caching of these objects, and we've run into a bit of a performance issue when it comes to doing these comparisons. Here's the workflow: Data item 1 is the curre...

Is passing a big structure pointer to a function cache effective?

Hello, If one has a big structure, having lot of member variables. Some function needs to access 4-5 elements in the structure for its working, so which of the below scenario could be cache effective(less cache misses)- 1.) Pass the pointer to the structure as argument to the function, Which in turn will access the needed elements.(Ass...

Efficient Huffman tree search while remembering path taken

As a follow up question related to my question regarding efficient way of storing huffman tree's I was wondering what would be the fastest and most efficient way of searching a binary tree (based on the Huffman coding output) and storing the path taken to a particular node. This is what I currently have: Add root node to queue while q...

A good architecture for Tagging items

Duplicate: How do you recommend implementing tags or tagging What's a efficient, fast and elegant architecture for a tagging system (such as posts or photos). For example, you have a site like StackOverflow and each item has a couple of tags. What's the best way to keep track of these, and make them searchable. Scalability is impor...

String concatenation in C# with interned strings

I know this question has been done but I have a slightly different twist to it. Several have pointed out that this is premature optimization, which is entirely true if I were asking for practicality's sake and practicality's sake only. My problem is rooted in a practical problem but I'm still curious nonetheless. I'm creating a bunc...

Unable to move fast between files in Vim

I have the following in my .Zshrc . /Users/Masi/bin/Zsh/prompt I need run the following code to access the file from .zshrc Ctrl-Z vim ~/bin/Zsh/prompt I tried to do the same unsuccessfully by first highlighting the path in visual mode and running :'<,'>!vim How can you move fast between files in Vim? ...

C++ Exp vs. Log: Which is faster?

I have a C++ application in which I need to compare two values and decide which is greater. The only complication is that one number is represented in log-space, the other is not. For example: double log_num_1 = log(1.23); double num_2 = 1.24; If I want to compare num_1 and num_2, I have to use either log() or exp(), and I'm wonderin...

Most efficient way to make sure a line exists in a plain text file

I'm using C# (.Net 2.0), and I have a fairly large text file (~1600 lines on average) that I need to check periodically to make sure a certain line of text is there. What is the most efficient way of doing this? Do I really have to load the entire file into memory each time? Is there a file-content-search api of some sort that I could...

How granular should data in memcached be?

Something I'm curious about.. What would be "most efficient" to cache the generation of, say, an RSS feed? Or an API response (like the response to /api/films/info/a12345). For example, should I cache the entire feed, and try and return that, as psuedo code: id = GET_PARAMS['id'] cached = memcache.get("feed_%s" % id) if cached is not N...

How can I make this query to detect multiple accounts more efficient & play well w/ has_many?

In my User model, I want to search for whether a user has multiple accounts (aka 'multis'). Users have sessions; sessions are customized to set creator_id = ID of first user the session was logged in as, and updater_id = ID of last user the session was logged in as (Both columns are indexed.) If I detect that the two are different...

Does setting Java objects to null do anything anymore?

I was browsing some old books and found a copy of "Practical Java" by Peter Hagger. In the performance section, there is a recommendation to set object references to null when no longer needed. In Java, does setting object references to null improve performance or garbage collection efficiency? If so, in what cases is this an issue? Co...

Help with slow UDF in SQL Server 2005

I have a table of dates call [BadDates], it has just one column where every record is a date to exclude. I have a UDF as follows: CREATE FUNCTION [dbo].[udf_GetDateInBusinessDays] ( @StartDate datetime, --Start Date @NumberDays int --Good days ahead ) RETURNS datetime AS BEGIN -- Declare the return variable here DECLARE ...

Faster enumeration: Leveraging Array Enumeration

So, I have a class with an array inside. Currently, my strategy for enumerating over the class's items is to use the code, foreach (item x in classInstance.InsideArray) . I would much rather use foreach (item x in classInstance) and make the array private. My main concern is that I really need to avoid anything slow; the array gets hi...

How do I get the Mac OS X 'quick look' feature to be more programmer-friendly?

There are numerous text files that are always included in common downloads such as rails plugins: LICENSE, ChangeLog, Rakefile, etc. I know these files are plain-text, but Mac OS X refuses to acknowledge this automatically. If I hit the spacebar in Finder to activate "quick look", the icon becomes huge but the contents of the file are n...

What's more costly on every page view - Database Writes or File Writes?

What is the most efficient solution when you need to record some data on every page view in your application - should you write to a file or write to the database? Or maybe neither - perhaps you should cache the data in memory or a file and only write it to the database (or file system if you use a memory cache) occasionally? ...

Analyzing Code for Efficiency?

What kinds of tools do you use to determine the efficiency of code? Do you use home grown applications that run a statistically significant number of tests, or some commercial product? Do you use your own knowledge to test certain areas of your code, or some tool that analyzes your code for weak spots? ...

WPF: More efficient way of displaying quickly-changing images?

I'm using the Image control to display an 8-bit grayscale image that I process myself on a background thread. Once the image is processed, I set the Image.BitmapSource property to point to a new bitmap I create via BitmapSource.Create(). This is all well and good - until I have to rapidly reprocess the image and throw it back on screen. ...