A colleague of mine today committed a class called ThreadLocalFormat, which basically moved instances of Java Format classes into a thread local, since they are not thread safe and "relatively expensive" to create. I wrote a quick test and calculated that I could create 200,000 instances a second, asked him was he creating that many, to ...
I need to do a fast case-insensitive substring search in C/C++. My requirements are as follows:
Should behave like strstr() (i.e. return a pointer to the match point).
Must be case-insensitive (doh).
Must support the current locale.
Must be available on Windows (MSVC++ 8.0) or easily portable to Windows (i.e. from an open source librar...
This is the way I read file:
public static string readFile(string path)
{
StringBuilder stringFromFile = new StringBuilder();
StreamReader SR;
string S;
SR = File.OpenText(path);
S = SR.ReadLine();
while (S != null)
{
stringFromFile.Append(SR.ReadLine());
...
I've read all the advice on const-correctness in C++ and that it is important (in part) because it helps the compiler to optimize your code. What I've never seen is a good explanation on how the compiler uses this information to optimize the code, not even the good books go on explaining what happens behind the curtains.
For example, ...
I would like to know if there are general rules for creating an index or not.
How do I choose which fields I should include in this index or when not to include them?
I know its always depends on the environement and the amount of data, but I was wondering if we could make some globally accepted rules about making indexes in Oracle.
...
As the title states, is there a way to prevent extra elements from showing up in VBA dynamic arrays when they are non-zero based?
For example, when using code similar to the following:
While Cells(ndx, 1).Value <> vbNullString
ReDim Preserve data(1 To (UBound(data) + 1))
ndx = ndx + 1
Wend
You have an extra empty array eleme...
We've got Ultraseek 5.7 indexing the content on our corporate intranet site, and we'd like to make sure our web pages are being optimized for it.
Which SEO techniques are useful for Ultraseek, and where can I find documentation about these features?
Features I've considered implementing:
Make the title and first H1 contain the most...
A long time ago when I was a young lat I used to do a lot of assembler and optimization programming. Today I mainly find myself building web apps (it's alright too...). However, whenever I create fields for database tables I find myself using values like 16, 32 & 128 for text fields and I try to combine boolean values into SET data field...
How fast is php_uname() say doing php_uname('s n') or php_uname('a'). The reason I ask is because I'd like to use it to determine which server I'm on and therefore the configuration (paths, etc).
This is related to Is there a PHP function or variable giving the local host name?
...
Today when I was in computer organization class, teacher talked about something interesting to me. When it comes to talk about Why cache memory works, he said that:
for (i=0; i<M; i++)
for(j=0; j<N; j++)
X[i][j] = X[i][j] + K; //X is double(8 bytes)
it is not good to change the first line with the second. What is your opinion...
SQL databases seem to be the cornerstone of most software. However, it seems optimized for textual data. In fact when doing any queries involving numerical data, integers specifically, it seems inefficient that the numbers are getting converted to text and then back to native formats both ways between the application and the database. Th...
In our desktop application, we have implemented a simple search engine using an inverted index.
Unfortunately, some of our users' datasets can get very large, e.g. taking up ~1GB of memory before the inverted index has been created. The inverted index itself takes up a lot of memory, almost as much as the data being indexed (another 1G...
At a previous employer, we were writing binary messages that had to go "over the wire" to other computers. Each message had a standard header something like:
class Header
{
int type;
int payloadLength;
};
All of the data was contiguous (header, immediately followed by data). We wanted to get to the payload given that we had ...
I am currently in a programming mentality that Reflection is my best friend. I use it a lot for dynamic loading of content that allows "loose implementation" rather than strict interfaces, as well as a lot of custom attributes.
The question I have is, what is the "real" cost to using reflection?
Is it worth the effort for frequently ...
I know several ways of writing paged query in SQL Server 2005. But I have no idea about their performance. Which one is the best and most optimized way for writing paging SQL queries?
Using Row_Number()
Using Partition by
Using Temporary tables
Using Nest Top N with Order by
Some other way?
...
I am working with a larger than average sqlite database (for use on both on windows and linux) and am looking to maximize the performance I get out of it. The database is to be installed on commodity hardware along with an sqlite gui. The users I am delivering this to are sql savvy but are unlikely to undertake their own optimizations (c...
Today i stumbled upon an interesting performance problem with a stored procedure running on Sql Server 2005 SP2 in a db running on compatible level of 80 (SQL2000).
The proc runs about 8 Minutes and the execution plan shows the usage of an index with an actual row count of 1.339.241.423 which is about factor 1000 higher than the "real"...
If I notice that a hash table (or any other data structure built on a hash table) is filling up, at what point should you build a new table with more buckets. And given n items in the table so far, how do you figure out how many buckets to use in the new one?
So let's say I have 100 buckets. Should I reorganize it when there are 50 item...
What techinques do you use? How do you find out which jobs take the longest to run? Is there a way to find out the offending applications?
...
I'm not talking about algorithmic stuff (eg use quicksort instead of bubblesort), and I'm not talking about simple things like loop unrolling.
I'm talking about the hardcore stuff. Like Tiny Teensy ELF, The Story of Mel; practically everything in the demoscene, and so on.
...