Creating DataTable performance problem

  • Thread starter Thread starter Michael Kugler
  • Start date Start date
M

Michael Kugler

Hi,

I have some performance problems creating a DataTable. I do some
calculations on the GPU with openCL. The calculations and returning the 64
mio rows takes about 0.19 sec.
Creating the datetable out of the array takes about 2 minutes :-(
Curently I do the creation like this (I already thought about
multithreading but i want the result sorted):
)
float[] result;
result=MatrixCalculationOpenCL(xSource, ySource, xDestination,
yDestination);
DataTable dt = new DataTable("AddressToAddress");
dt.Columns.Add("SourceAdress",typeof(int));
dt.Columns.Add("DestinationAddress", typeof(int));
dt.Columns.Add("Distance", typeof(float));

for (int i = 0; i < iSourceAdress.Length; i++)

{
for (int ii = 0; ii < iSourceAdress.Length; ii++)
{
DataRow dr;
dr = dt.NewRow();
dr.ItemArray[0] = iSourceAdress;
dr.ItemArray[1] = iSourceAdress;
dr.ItemArray[2] = result[(i*iSourceAdress.Length)+ii];
dt.Rows.Add(dr);
}
}


Regards

Michael
 
Michael Kugler said:
Hi,

I have some performance problems creating a DataTable. I do some

Why do you need a datatable?
A typed list would be quicker.
Just using your array would be instant.

So why a datatable?
 
Back
Top