I need a class that implements Iterable, and does not need to be safe for concurrent usage. Of the various options, such as LinkedList, HashSet, ArrayList etc, which is the lightest-weight?
To clarify the use-case, I need to be able to add a number of objects to the Iterable (typically 3 or 4), and then something else needs to iterate ...
I have historically used a monolithic approach to PHP coding.
That is, I write one index.php, with an average size of 70k-250k, and use
mod_rewrite
to turn the rest of the
REQUEST_URI
into parameters passed into the index.php to control what is happening.
The alternative would be to write many small php scripts, each specialize...
I have a table with 117000 or so records. I need to perform a search that checks 3 separate fields for a given string pattern.
My where clause is as follows:
field1 LIKE '%' + @DESC + '%'
OR field2 LIKE '%' + @DESC + '%'
OR field3 LIKE '%' + @DESC + '%'
This seems to take about 24 seconds regardless of input...
Is there a better way ...
In the past when working with databases I've found it necessary to do low-level tweaks to the query, for example providing hints to the optimiser that it should use a particular index or join order. We are currently considering rewriting our data layer using Entity Framework; is it the case that using EF prevents this sort of low-level o...
Hi
I am doing project euler question 63 where I must find the amount of numbers that exist where:
x^(n) == y
Where n is the length of y.
It soon emerges that the results for this condition alternate between odd and even and so I came up with this in Haskell:
prob63 = [ n | n <- nums n , i <-[1..10], i^(length $ show n) == n]
nums n...
I have a C# app in which I am testing 3 ways to do something with XML.
I read a string of XML get a value out and then add it to a custom collection.
I am testing XMLDocument, XDocument and String manipulation to find the node value, in that order recording a start and end time for each.
However if I say mix the order up I get differe...
I know that I can iterate over an object's properties like this:
for (property in object)
{
// do stuff
}
I also know that the fastest way to iterate over an array in Javascript is to use a decreasing while loop:
var i = myArray.length;
while (i--)
{
// do stuff fast
}
I'm wondering if there is something similar to a decrea...
UPDATE Sept 11 2010:
A testing platform has been created for this here
HTTP 1.1 definitions of GZIP and DEFLATE (zlib) for some background information:
" 'Gzip' is the gzip format, and 'deflate' is the zlib format. They
should probably have called the second one 'zlib' instead to avoid
confusion with the raw deflate compressed ...
I have a couple uint8_t arrays in my c code, and I'd like to compare an arbitrary sequence bits from one with another. So for example, I have bitarray_1 and bitarray_2, and I'd like to compare bits 13 - 47 from bitarray_1 with bits 5-39 of bitarray_2. What is the most efficient way to do this?
Currently it's a huge bottleneck in my pro...
Basically I'm trying to pull a random poll question that a user has not yet responded to from a database. This query takes about 10-20 seconds to execute, which is obviously no good! The responses table is about 30K rows and the database also has about 300 questions.
SELECT questions.id
FROM questions
LEFT JOIN responses ON ( questi...
I have just converted a SQL select statement into a stored procedure
The SQL Statement use select statement takes
0.4784s to run the first time and 0.0003s after that
The Stored procedure takes 0.4784s to run every time.
I assume the query cache is not been used
How can I rectify this?
A simplified version of the code
SELECT * FRO...
In my language I can use a class variable in my method when the definition appears below the method. It can also call methods below my method and etc. There are no 'headers'. Take this C# example.
class A
{
public void callMethods() { print(); B b; b.notYetSeen();
public void print() { Console.Write("v = {0}", v); }
int v=9;...
I'm looking to find bottlenecks in my Java application in Eclipse. I'm thinking this might be useful:
http://www.eclipse.org/projects/project%5Fsummary.php?projectid=tptp.performance
Any other good plug-ins to use?
EDIT OK, it doesn't necessarily have to be an Eclipse plug-in. But it would be nice. And, I'm most interested in speed.
...
I rewrote a number-crunching two pages of code from C# to unmanaged C++ in my project, which with full optimizations gave a 3x speedup. I want to keep optimizing that code, but now my profiler of choice, dotTrace, can't do it, because it only looks at managed code.
How do I profile the P/Invoked C++ module when it's running in the C# ap...
I'm reading Joe Duffy's post about Volatile reads and writes, and timeliness, and i'm trying to understand something about the last code sample in the post:
while (Interlocked.CompareExchange(ref m_state, 1, 0) != 0) ;
m_state = 0;
while (Interlocked.CompareExchange(ref m_state, 1, 0) != 0) ;
m_state = 0;
…
When the second CMPXCHG o...
I execute the next code:
(take 10) $! [1,2..]
What is it ? I thought, ghc will yield a termination, beacause i say "evaluate [1,2..] force". But I got the result "[1,2,3,4,5,6,7,8,9,10]".
...
This method is a bottleneck in my program. (Or, it is at least where most of the time is being spent.)
Its purpose is to calculate the similarity between two strings based on the way characters occur in both, or occur in one or not the other.
The code is correct, but I would like to optimize it. Do you see any inefficiencies, bad pract...
Hello,
I have a hardcoded list of values like: 1,5,7,8 and so on.
And I must filter out rows from table that have ID in list above, so I do something like this:
Select
*
from myTable m
left join othertable t
on t.REF_ID = m.ID
where m.ID not in (1,5,7,8...)
But when I have more values (like 1000) and more rows (100) in other...
I have a table with 16 columns. It will be most frequently used table in web aplication and it will contain about few hundred tousand rows. Database is created on sql server 2008.
My question is choice for primary key. What is quicker? I can use complex primary key with two bigint-s or i can use one varchar value but i will need to con...
Hey Everyone,
Our initial page load is a beast in our Rails app. The great thing about it is the lack of page refreshes needed. The whole thing is very Ajax-y (and our designers made it look great!) There is only one problem: Initial page load is a monster.
I have tweaked and prodded and have eeked out incredible speed improvements b...