Should try…catch go inside or outside a loop?

PERFORMANCE: There is absolutely no performance difference in where the try/catch structures are placed. Internally, they are implemented as a code-range table in a structure that is created when the method is called. While the method is executing, the try/catch structures are completely out of the picture unless a throw occurs, then the location of … Read more

MySQL OR vs IN performance

I needed to know this for sure, so I benchmarked both methods. I consistenly found IN to be much faster than using OR. Do not believe people who give their “opinion”, science is all about testing and evidence. I ran a loop of 1000x the equivalent queries (for consistency, I used sql_no_cache): IN: 2.34969592094s OR: … Read more

How do I speed up the gwt compiler?

Let’s start with the uncomfortable truth: GWT compiler performance is really lousy. You can use some hacks here and there, but you’re not going to get significantly better performance. A nice performance hack you can do is to compile for only specific browsers, by inserting the following line in your gwt.xml: <define-property name=”user.agent” values=”ie6,gecko,gecko1_8″></define-property> or … Read more

Does the C++ standard mandate poor performance for iostreams, or am I just dealing with a poor implementation?

Not answering the specifics of your question so much as the title: the 2006 Technical Report on C++ Performance has an interesting section on IOStreams (p.68). Most relevant to your question is in Section 6.1.2 (“Execution Speed”): Since certain aspects of IOStreams processing are distributed over multiple facets, it appears that the Standard mandates an … Read more

Check if property has attribute

There’s no fast way to retrieve attributes. But code ought to look like this (credit to Aaronaught): var t = typeof(YourClass); var pi = t.GetProperty(“Id”); var hasIsIdentity = Attribute.IsDefined(pi, typeof(IsIdentity)); If you need to retrieve attribute properties then var t = typeof(YourClass); var pi = t.GetProperty(“Id”); var attr = (IsIdentity[])pi.GetCustomAttributes(typeof(IsIdentity), false); if (attr.Length > 0) … Read more