A simple Q: there any performance penalty by extensive data bindin

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have like 50 controls from data grid and textboxes bound to a dataset in
windows form. Some one told me the extensive data binding will slow down the
aplication.

Does it really perform slower than manually set the textbox values by
"ControName.Text=ValueString"?
 
Yes it will.

Databinding uses reflection to peform it's operations. Reflection is
multitudes slower than using strongly types without boxing.

However, when that is said I do not think that the use of reflection will
have any significant meaning when used in a UI as databainding is. Drawing
stuff to the screen, loading the forms and the controls and all that will
problably takes huge more amount of time than the actually time used to
set/get the values using databinding.

If you try to do something like this:
class MyClass{
private int _value = 0;
public void AddValue(int value)
_value += value;
}
}

and then:
MyClass myClass = new myClass();
for(int n = 0; n < 100000; n++){
myClass.AddValue(n);
}
vs this:
MethodInfo method = myClass.GetType().GetMethod ... dont remember exact
syntax
for(int n = 0; n < 100000; n++){
method.Invoke(myClass, new object[]{n});
}

You are likely to see a huge amount of difference is speed when peforming
the operations this way.


The speed issue I'm sure of (have tested it in practice), the databinding
stuff is a bit more guessing.
Also, as databinding uses a lot of mechanism to keep infor syncronized (in
both directions) it migth be other issues than just the use of reflections
that comes into play.

regards, TEK
 
I tested the pice code you provided, and the results for 1,000,000 iterations
is 16 milliseconds and 7000 milliseconds.
Though it is significant slower, the actual case will not have such
extensive usage of reflection.
Do you aslo mean that "Drawing stuff to the screen, loading the forms and
the controls and all that will problably takes huge more amount of time"
could be caused by the databindings?

TEK said:
Yes it will.

Databinding uses reflection to peform it's operations. Reflection is
multitudes slower than using strongly types without boxing.

However, when that is said I do not think that the use of reflection will
have any significant meaning when used in a UI as databainding is. Drawing
stuff to the screen, loading the forms and the controls and all that will
problably takes huge more amount of time than the actually time used to
set/get the values using databinding.

If you try to do something like this:
class MyClass{
private int _value = 0;
public void AddValue(int value)
_value += value;
}
}

and then:
MyClass myClass = new myClass();
for(int n = 0; n < 100000; n++){
myClass.AddValue(n);
}
vs this:
MethodInfo method = myClass.GetType().GetMethod ... dont remember exact
syntax
for(int n = 0; n < 100000; n++){
method.Invoke(myClass, new object[]{n});
}

You are likely to see a huge amount of difference is speed when peforming
the operations this way.


The speed issue I'm sure of (have tested it in practice), the databinding
stuff is a bit more guessing.
Also, as databinding uses a lot of mechanism to keep infor syncronized (in
both directions) it migth be other issues than just the use of reflections
that comes into play.

regards, TEK

zhaounknown said:
I have like 50 controls from data grid and textboxes bound to a dataset in
windows form. Some one told me the extensive data binding will slow down
the
aplication.

Does it really perform slower than manually set the textbox values by
"ControName.Text=ValueString"?
 
Back
Top