I have come across a lot of optimization tips which say that you should mark your classes as sealed to get extra performance benefits.
I ran some tests to check the performance differential and found none. Am I doing something wrong? Am I missing the case where sealed classes will give better results?
Has anyone run tests and seen a di...
I'm wondering if it's a good idea to make verifications in getters and setters or elsewhere in the code.
This might surprise you be when it comes to optimizations and speed-ing up the code, I think you should not made verifications in getters and setters but in the code where your're updating your files or database. Am I wrong ?...
Most people with a degree in CS will certainly know what Big O stands for.
It helps us to measure how (in)efficient an algorithm really is and if you know in what category the problem you are trying to solve lays in you can figure out if it is still possible to squeeze out that little extra performance.*
But I'm curious, how do you calc...
I have come across the following type of code many a times, and I wonder if this is a good practice (from Performance perspective) or not:
try
{
... // some code
}
catch (Exception ex)
{
... // Do something
throw new CustomException(ex);
}
Basically, what the coder is doing is that they are encompassing the exception in a ...
Which is more efficient for the compiler and the best practice for checking whether a string is blank?
Checking whether the length of the string == 0
Checking whether the string is empty (strVar == "")
Also, does the answer depend on language?
...
In Maybe Normalizing Isn't Normal Jeff Atwood says, "You're automatically measuring all the queries that flow through your software, right?" I'm not but I'd like to.
Some features of the application in question:
ASP.NET
a data access layer which depends on the MS Enterprise Library Data Access Application Block
MS SQL Server
...
I have an Ajax.Net enabled ASP.Net 2.0 web site. Hosting for both the site and the database are out of my control as is the database's schema. In testing on hardware I do control the site performs well however on the client's hardware, there are noticeable delays when reloading or changing pages.
What I would like to do is make my appl...
std::swap() is used by many std containers (such as std::list and std::vector) during sorting and even assignment.
But the std implementation of swap() is very generalized and rather inefficient for custom types.
Thus efficiency can be gained by overloading std::swap() with a custom type specific implementation. But how can you impleme...
I have a query where I am searching against a string:
SELECT county FROM city WHERE UPPER(name) = 'SAN FRANCISCO';
Now, this works fine, but it doesn't scale well, and I need to optimize it. I have found an option along the lines of creating a generated view, or something like that, but I was hoping for a simpler solution using an in...
(assume php5) consider
<?php
$foo = 'some words';
//case 1
print "these are $foo";
//case 2
print "these are {$foo}";
//case 3
print 'these are ' . $foo;
Is there much of a difference between 1 and 2?
If not, what about between 1/2 and 3?
...
I know that .NET is JIT compiled to the architecture you are running on just before the app runs, but does the JIT compiler optimize for 64bit architecture at all? Is there anything that needs to be done or considered when programming an app that will run on a 64bit system? (i.e. Will using Int64 improve performance and will the JIT com...
Can the performance of this sequential search algorithm (taken from
The Practice of Programming) be improved using any of C's native utilities, e.g. if I set the i variable to be a register variable ?
int lookup(char *word, char*array[])
{
int i
for (i = 0; array[i] != NULL; i++)
if (strcmp(word, array[i]) == 0)
...
What would be the most efficient way to compare two doubles or two floats (single precision)?
Simply doing this is not correct:
bool CompareDoubles1 (double A, double B)
{
return A == B;
}
But something like:
bool CompareDoubles2 (double A, double B)
{
diff = A - B;
return (diff < EPSILON) && (-diff > EPSILON);
}
Seems t...
When I am writing code in Python, I often need to remove items from a list or other sequence type based on some criteria. I haven't found a solution that is elegant and efficient, as removing items from a list you are currently iterating through is bad. For example, you can't do this:
for name in names:
if name[-5:] == 'Smith':
...
What are all the possible ways in which we can get memory leaks in .NET?
I know of two:
Not properly un-registering Event Handlers/Delegates.
Not disposing dynamic child controls in Windows Forms:
Example:
// Causes Leaks
Label label = new Label();
this.Controls.Add(label);
this.Controls.Remove(label);
// Correct Code
La...
What's the most efficient way to concatenate strings?
...
My knowledge of SQL has been mostly gathered through immediate need as opposed to formal training. The project I'm working on now requires the next level of SQL (specifically SQL Server 2005) knowledge. That is, I need to know techniques for optimizing the schema, writing optimized queries and even some information about replication an...
I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program to other users. Its going to web-based and hosted on our servers.
I'm using a simple All...
Is there a performance difference between i++ and ++i if the resulting value is not used?
...
We looked at this answer for C in this question:
http://stackoverflow.com/questions/24886/is-there-a-performance-difference-between-i-and-i-in-c
What's the answer for C++?
...