Creating DataTable performance problem

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
 
A

Andy O'Neill

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top