quwiltw
Contributor
I'm seeing some unexpected behavior and hoping someone can explain it. I'm creating 10,000 instances each of an OleDbConnection, OleDbDataAdapter, and OleDbCommand using
and it takes ~820 milliseconds
Then I'm 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 I'm also accepting a hashtable of properties/values to be dynamically assigned after the creation too. Can anyone explain the slower performance of "New"? It's not a big deal because I'm getting even better than what I was hoping for but I find it curious anyway.
Visual Basic:
Dim cn As New OleDbConnection(cnStr)
etc.
Then I'm creating 10,000 instances of each of those using
Visual Basic:
obj = Activator.CreateInstance(GetCurrentHash.Item(interfaceName))
I was expecting the opposite and CreateInstance to be slower, mainly because of the initial Type lookup and I'm also accepting a hashtable of properties/values to be dynamically assigned after the creation too. Can anyone explain the slower performance of "New"? It's not a big deal because I'm getting even better than what I was hoping for but I find it curious anyway.