quwiltw
Well-known member
Im seeing some unexpected behavior and hoping someone can explain it. Im creating 10,000 instances each of an OleDbConnection, OleDbDataAdapter, and OleDbCommand using
and it takes ~820 milliseconds
Then Im creating 10,000 instances of each of those using
where GetCurrentHash... returns a cached "Type" to create. This is only taking ~680 milliseconds.
I was expecting the opposite and CreateInstance to be slower, mainly because of the initial Type lookup and Im also accepting a hashtable of properties/values to be dynamically assigned after the creation too. Can anyone explain the slower performance of "New"? Its not a big deal because Im getting even better than what I was hoping for but I find it curious anyway.
Code:
Dim cn As New OleDbConnection(cnStr)
etc.
Then Im creating 10,000 instances of each of those using
Code:
obj = Activator.CreateInstance(GetCurrentHash.Item(interfaceName))
I was expecting the opposite and CreateInstance to be slower, mainly because of the initial Type lookup and Im also accepting a hashtable of properties/values to be dynamically assigned after the creation too. Can anyone explain the slower performance of "New"? Its not a big deal because Im getting even better than what I was hoping for but I find it curious anyway.