Advantages to Using Private Static Methods

From the FxCop rule page on this: After you mark the methods as static, the compiler will emit non-virtual call sites to these members. Emitting non-virtual call sites will prevent a check at runtime for each call that ensures that the current object pointer is non-null. This can result in a measurable performance gain for … Read more

Is std::vector so much slower than plain arrays?

Using the following: g++ -O3 Time.cpp -I <MyBoost> ./a.out UseArray completed in 2.196 seconds UseVector completed in 4.412 seconds UseVectorPushBack completed in 8.017 seconds The whole thing completed in 14.626 seconds So array is twice as quick as vector. But after looking at the code in more detail this is expected; as you run across … Read more

Optimise PostgreSQL for fast testing

First, always use the latest version of PostgreSQL. Performance improvements are always coming, so you’re probably wasting your time if you’re tuning an old version. For example, PostgreSQL 9.2 significantly improves the speed of TRUNCATE and of course adds index-only scans. Even minor releases should always be followed; see the version policy. Don’ts Do NOT … Read more

In general is it better to use one or many useEffect hooks in a single component? [closed]

The pattern that you need to follow depends on your use case. First: You might have a situation where you need to add event listener during the initial mount and clean them up at unmount and another case where a particular listener needs to be cleaned up and re-added on a prop change. In such … Read more

Should I use Java’s String.format() if performance is important?

I took hhafez code and added a memory test: private static void test() { Runtime runtime = Runtime.getRuntime(); long memory; … memory = runtime.freeMemory(); // for loop code memory = memory-runtime.freeMemory(); I run this separately for each approach, the ‘+’ operator, String.format and StringBuilder (calling toString()), so the memory used will not be affected by … Read more