What does it mean to 'hash cons'?
When to use it and why? My question comes from the sentence: "hash cons with some classes and compare their instances with reference equality" ...
When to use it and why? My question comes from the sentence: "hash cons with some classes and compare their instances with reference equality" ...
I have a very large table with a fulltext indexed column. If I partition this table sensibly (for me, sensibly is by date), will it speed up queries? Or will the full text clause still search through the whole table, even if the query limits to a single partition? From what I've seen so far, I think the answer is partitioning won't help...
I've written a helper class that takes a string in the constructor and provides a lot of Get properties to return various aspects of the string. Currently the only way to set the line is through the constructor and once it is set it cannot be changed. Since this class only has one internal variable (the string) I was wondering if I shoul...
I was studying deconvolution, and stumbled upon Richardson-Lucy deconvolution, I was thinking of writing a simple program to do post-processing using this method, does anybody know where I can find complete implementable algorithms or source code that I can study and play around with? Preferably in C++ language or matlab. I have r...
Hey Guys, Just wondering what the best tool is to really check JS scripts and look at ways of improving overall performance to the "utmost maximum" in terms of size and speed? ...
I'm writing a DSP application in C# (basically a multitrack editor). I've been profiling it for quite some time on different machines and I've noticed some 'curious' things. On my home machine, the first run of the playback loop takes up about 50%-60% of the available time, (I assume it's due to the JIT doing its job), then for the sub...
In part of our application we have the ability to search for music. The search results are loaded into a gridview which lists the song name, the artist, the royalty required for use, and a small flash object which plays a preview when clicked (wimpy button from this site) When the users search returns a large number of results, it take...
I am looking for an efficient way to determine the position of the least significant bit that is set in an integer, e.g. for 0x0FF0 it would be 4. A trivial implementation is this: unsigned GetLowestBitPos(unsigned value) { assert(value != 0); // handled separately unsigned pos = 0; while (!(value & 1)) { value >>= ...
Hi guys and girls, I'm writing a method to return an 'asset' row from the database. It contains strings, ints and a byte array (this could be an image/movie/document). Now for most row access I use the following method which returns a NameValueCollection as it is a light weight object, easy to use and cast int and strings. p...
Hi all, I have child classes, each carries a different type of value along with other members. There may be a LongObject, IntObject, StringObject, etc. I will be given a value, which can be a long, int, string, etc., and I have to create a LongObject, IntObject, StringObject, etc., respectively. Would it be faster to overload a met...
After prepairing an answer for this question I found I couldn't verify my answer. In my first programming job I was told that a query within the IN () predicate gets executed for every row contained in the parent query, and therefore using IN should be avoided. For example, given the query: SELECT count(*) FROM Table1 WHERE Table1Id N...
I have this function whose essential operations are outlined as follows: function render($index) { foreach($things[$index] as $key => $data) { echo '<div>'; /* irrelevant operations */ if(isset($data['id'])) { echo '<div class="wrap">'; render($things[$data['id']]); echo '<...
I was changing my for loop to increment using ++i instead of i++ and got to thinking, is this really necessary anymore? Surely today's compilers do this optimization on their own. In this article, http://leto.net/docs/C-optimization.php, from 1997 Michael Lee goes into other optimizations such as inlining, loop unrolling, loop jammin...
Hi, I am trying to optimize my MySQL queries and I need some help. Here is my current query : SELECT *, (SELECT name FROM stores WHERE id = products.store_id) AS store_name, (SELECT username FROM stores WHERE id = products.store_id) AS store_username, (SELECT region_id FROM stores WHERE id = products.store_id) AS re...
I'm not sure how to explain the behavior I'm seeing, but here goes. I have a function foo that takes three parameters, a pointer, an int, and another pointer. When I break-point inside foo, I can clearly see that all the variables are the values they should be. However, when I step down beyond the local variable declarations, one of t...
If I just want to do a quick measurement of how long a particular function is taking, what can I call to get an accurate timing? Given that the VB6 timing functions aren't high precision, are there Windows API functions you call instead? In what other ways do you measure application performance? Are there any third-party tools that you ...
I am currently developing on an advertising system, which have been running just fine for a while now, apart from recently when our views per day have shot up from about 7k to 328k. Our server cannot take the pressure on this anymore - and knowing that I am not the best SQL guy around (hey, I can make it work, but not always in the best ...
When SHOW WARNINGS after a EXPLAIN EXTENDED shows a Note 1276 Field or reference 'test.foo.bar' of SELECT #2 was resolved in SELECT #1 what exactly does that mean and what impact does it have? In my case it prevents mysql from using what seems to be a perfectly good index. But it's not about fixing that specific query (as it is an irr...
It's an implementation of Sieve of Eratosthenes. class PrimeGenerator def self.get_primes_between( x, y) sieve_array = Array.new(y) {|index| (index == 0 ? 0 : index+1) } position_when_we_can_stop_checking = Math.sqrt(y).to_i (2..position_when_we_can_stop_checking).each{|factor| sieve_array[(factor).. (y-1)...
This is a canonical question, meant only half-way as a joke. Hopefully, you'll find this before posting any question of the form: Is something faster than something else? Hopefully, the answers below will educate you and prevent you from asking any such questions. Make sure you answer it, bods. I've posted my own thoughts but I've...