I have a routine that is importing Foxpro Data. This week made some changes and added a few larger tables(more records and more fields) to the import routine that has been running for months. These "new" tables are by no means crazy huge as the largest one is right around 75,000 records and 30 or so fields. This routine has been running at night so I never really noticed if this has always been an issue. however while debugging changes noticed that the performance was lacking..
Once I started looking onto it I was very suprised at the perfomance vs a plain datatable. I did expect a business object to have some additional overhead over a vanilla datatable , however I was expecting a very minimal difference compared to the results I am seeing. Perhaps I am missing something easy like not setting a business object property or I am looking at something completly wrong. Whatever it is there seems to be a huge performance difference that I would like to get to the bottom of it.
To take anything I was doing out of the mix I created a test project that uses the stataframe sample orderitems table as a source and destination bo. I then created a standard plain old vanilla BO mapped to the items table. The only business object property that is changed from default is the "allowsnullvaluesonnewrow" is set to true.
Basically I fill a 'source' business object Then loop through the 'source' business object and create a new row on a destination object and sets the value of a field on the destination object from the source .
Business Object Example
'Set Start Time
starttime = DateTime.Now
'Loop through filled Business ObjectFor Each bo As itemsbo In SourceBO.GetEnumerable'Create New Row in Destination Business ObjectDestinationBO.NewRow()
'Set Value of 1 fieldDestinationBO.orit_Quantity = bo.orit_Quantity
Next'Set Stop Timestoptime = DateTime.Now
'Set Elapsedelapsed_time = stoptime.Subtract(starttime)
Same routine using a vanilla datatable.
'Set Start Time
starttime = DateTime.Now
'Loop through filled Business ObjectFor Each bo As itemsbo In SourceBO.GetEnumerablelorow = dt.NewRow
'-- Set Value of 1 fldlorow("orit_Quantity") = bo.orit_Quantity
'-- Add the new row to the data table
dt.Rows.Add(lorow)
Next
'Set Stop Timestoptime = DateTime.Now
'Set Elapsedelapsed_time = stoptime.Subtract(starttime)
Here are my results based on 50,000 records from the strataframe order items table. These times do not include any filling of data or saving of data.
Use a bo to create a new row and set no values .54 seconds
use a bo to create a new row and set the value of one field 5.04 seconds
use a bo to create a new row and set the value of two fields 9.51 seconds
use a bo to create a new row and set the value of 3 fields 14.17 seconds
----------------Data Table--------
Use a datatable to create a new row and set no values .21 seconds
use a dt to create a new row and set the value of one field .31 seconds
use a dt to create a new row and set the value of two field .45 seconds
use a dt to create a new row and set the value of 3 fields .51 seconds