Parameter Binding Performance

Here is a short but important question that has come up repeatedly concerning the performance of parameter bindings.

Question: There is a big problem in the early versions of Revit 2009 with the performance of the Document ParameterBindings property, for example in the last line of the following code:

Application app = commandData.Application;
Document doc = app.ActiveDocument;
BindingMap bindingMap = doc.ParameterBindings;

The last statement takes a huge amount of time to execute, in the order of minutes. Are there any known solutions for this?

Answer: Good news: this performance delay was analysed and reported by Saikat Bhattacharya and fixed in the Revit 2009 Web Update 3. The issue is mentioned in the associated PDF file containing the list of enhancements:

API Enhancements

So all you need to do is install the updated version of Revit 2009 and the problem disappears. Many thanks to Saikat for pointing this out.