Now I realize this is a kind of weird question but here it is:
Let us assume I redraw all the controls by myself rather than using the default provided ones (Obviously I’m talking of winforms as WPF is already a custom drawn control set and winforms are just a way to access the Win32 API). Now I make an application with my custom-drawn controls. Then I make an application with winforms, which, in turn, uses the Win32 API. Now, when I run both the applications, will there be any performance difference? If yes, which will perform better?
Now comes the main question:
How (and based on what factor(s)) do you decide / predict as to which will perform better?
P.S. Forgive me if I am not clear enough. I always have trouble expressing my thoughts.
Remember that .NET Framework BCL code is optimized for being useful to the largest number of programmers, not for good performance in your particular application. So it’s highly likely that you can beat the performance of any particular piece of it, even if you aren’t a Rico Mariani.
However, you should learn from those experts, in particular mantras like “Measure, Measure, Measure”. This doesn’t mean you have to build and debug your version completely before figuring out whether you can beat the BCL. It does mean you identify which portions of the library code are causing you performance issues, so you don’t waste effort re-inventing what doesn’t matter.
Once you know how good or bad the performance of the general-purpose code is, you stand a good chance of predicting whether you’ll be able to beat it. Especially if you run some scalability tests. There are lots of framework-provided widgets where simple operations like adding multiple listbox items1 have quadratic (or worse) complexity… simply because the largest number of applications never put more than two dozen items in the control anyway. Armed with an estimate of the standard widget’s runtime (and memory) complexity for the operations you need, you’ll know exactly where you have the opportunity to do better in a way that pays dividends on your effort.
1 Sometimes the documentation points these out and even provides a way to plug in optimized-for-the-application code without throwing away the whole library component. For example, ListView “virtual mode”, or “Owner-Draw” for the tradition Win32 controls.
2
You don’t “decide/predict” those things. Similarly, you don’t predict where a bottleneck is.
If you need to know which solution is faster, you do both, and then compare the benchmarking results.
You understand that the result will depend, among others, on how good your optimization skills are compared to the skills of Microsoft developers, and we can’t possibly know how good you are, right?
There are many parameters involved in performance: your profiling/optimization skills, but also purely technical ones, like the number of layers of abstraction. You may obtain excellent performance results for a home-made solution made during a weekend. Or you may spend months profiling and optimizing your app and still be behind .NET Framework’s performance. Unless you actually do the test, you can’t know the answer.
3