Iterating in a list of data and search data in another datatableSearch datatable fasterConverting List to a...
Email Account under attack (really) - anything I can do?
Is there a way to make member function NOT callable from constructor?
What is it called when one voice type sings a 'solo'?
Are white and non-white police officers equally likely to kill black suspects?
Is it wise to focus on putting odd beats on left when playing double bass drums?
LWC and complex parameters
Pristine Bit Checking
What happens when a metallic dragon and a chromatic dragon mate?
New order #4: World
Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?
What do the Banks children have against barley water?
COUNT(*) or MAX(id) - which is faster?
Can I find out the caloric content of bread by dehydrating it?
Does it makes sense to buy a new cycle to learn riding?
Is it wise to hold on to stock that has plummeted and then stabilized?
Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?
What is the command to reset a PC without deleting any files
Are objects structures and/or vice versa?
What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?
Typesetting a double Over Dot on top of a symbol
"My colleague's body is amazing"
How can I plot a Farey diagram?
Does bootstrapped regression allow for inference?
Re-submission of rejected manuscript without informing co-authors
Iterating in a list of data and search data in another datatable
Search datatable fasterConverting List to a DataTable and/or DataSet Extension MethodsSpeeding up Parallel.ForEach iterating through datatable and rendering reportConvert datagridview data to DataTableList<List<string>> vs DataTableSort and merge list based on another listAdd data to DataTableLeetcode 10: Regular Expression MatchingList of classes to datatableHandler for jQuery DataTable search with filters and pagination
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$begingroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
{
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
{
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
}
if (File.Exists(savepath))
{
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
}
if (QcCommentFileExist && QcViewAllFileExist)
{
if (QCCommentstmp.Tables.Count > 0)
{
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
{
AllowUpdate = true;
}
}
if (AllowUpdate)
{
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
{
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
}).ToList();
if (QCCommentlist != null)
{
foreach (var comment in QCCommentlist)
{
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
{
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new { x.ColumnName }).FirstOrDefault();
if (QcViewColumnName != null)
{
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
{
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
{
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
{
comment.IgnoreData = strQCPeriodValue;
counter++;
}
}
}
}
}
}
}
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
}
}
}
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
New contributor
$endgroup$
add a comment |
$begingroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
{
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
{
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
}
if (File.Exists(savepath))
{
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
}
if (QcCommentFileExist && QcViewAllFileExist)
{
if (QCCommentstmp.Tables.Count > 0)
{
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
{
AllowUpdate = true;
}
}
if (AllowUpdate)
{
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
{
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
}).ToList();
if (QCCommentlist != null)
{
foreach (var comment in QCCommentlist)
{
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
{
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new { x.ColumnName }).FirstOrDefault();
if (QcViewColumnName != null)
{
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
{
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
{
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
{
comment.IgnoreData = strQCPeriodValue;
counter++;
}
}
}
}
}
}
}
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
}
}
}
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
New contributor
$endgroup$
2
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
2 days ago
$begingroup$
should i use parallel foreach instead of normal foreach to get better performance?
$endgroup$
– user197025
yesterday
add a comment |
$begingroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
{
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
{
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
}
if (File.Exists(savepath))
{
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
}
if (QcCommentFileExist && QcViewAllFileExist)
{
if (QCCommentstmp.Tables.Count > 0)
{
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
{
AllowUpdate = true;
}
}
if (AllowUpdate)
{
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
{
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
}).ToList();
if (QCCommentlist != null)
{
foreach (var comment in QCCommentlist)
{
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
{
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new { x.ColumnName }).FirstOrDefault();
if (QcViewColumnName != null)
{
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
{
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
{
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
{
comment.IgnoreData = strQCPeriodValue;
counter++;
}
}
}
}
}
}
}
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
}
}
}
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
New contributor
$endgroup$
I have a list which has 25000 data and I am iterating in all data and in each iteration, I am searching data in another data table. my whole routine is taking a long time to finish.
private void UpdateCommentFirst(string strCommentPath, string TickerName)
{
int counter = 0;
bool QcViewAllFileExist = false;
bool QcCommentFileExist = false;
bool AllowUpdate = false;
string savepath = Convert.ToString(ConfigurationManager.AppSettings["OutputPath"]).Trim() + TickerName + "\" + TickerName + "_QC-ViewwAll.xml";
DataSet QCCommentstmp = new DataSet();
DataSet QCViewAlltmp = new DataSet();
if (File.Exists(strCommentPath))
{
QCCommentstmp.ReadXml(strCommentPath);
QcCommentFileExist = true;
}
if (File.Exists(savepath))
{
QCViewAlltmp.ReadXml(savepath);
QcViewAllFileExist = true;
}
if (QcCommentFileExist && QcViewAllFileExist)
{
if (QCCommentstmp.Tables.Count > 0)
{
if (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData"))
{
AllowUpdate = true;
}
}
if (AllowUpdate)
{
List<clsCommentPopup> QCCommentlist = QCCommentstmp.Tables[0].AsEnumerable()
.Select(row => new clsCommentPopup
{
//BrokerFor,Formula,LineItem,Section,PeriodCollection
bolFollowUP = (row.Field<string>("FollowUP")) == null ? false : Convert.ToBoolean((row.Field<string>("FollowUP"))),
bolThisPeriod = (row.Field<string>("ThisPeriod")) == null ? false : Convert.ToBoolean((row.Field<string>("ThisPeriod"))),
Formula = (row.Field<string>("Formula")) == null ? string.Empty : (row.Field<string>("Formula")),
ModelValue = (row.Field<string>("ModelValue")) == null ? string.Empty : (row.Field<string>("ModelValue")),
ExternalComment = (row.Field<string>("ExternalComment")) == null ? string.Empty : (row.Field<string>("ExternalComment")),
InternalComment = (row.Field<string>("InternalComment")) == null ? string.Empty : (row.Field<string>("InternalComment")),
strEndPeriod = (row.Field<string>("EndPeriod")) == null ? string.Empty : (row.Field<string>("EndPeriod")),
strStartPeriod = (row.Field<string>("StartPeriod")) == null ? string.Empty : (row.Field<string>("StartPeriod")),
PeriodType = (row.Field<string>("PeriodType")) == null ? string.Empty : (row.Field<string>("PeriodType")),
SectionFor = (row.Field<string>("Section")) == null ? string.Empty : (row.Field<string>("Section")),
LiFor = (row.Field<string>("LineItem")) == null ? string.Empty : (row.Field<string>("LineItem")),
QcPeriodFor = (row.Field<string>("QcPeriod")) == null ? string.Empty : (row.Field<string>("QcPeriod")),
BrokerFor = (row.Field<string>("BrokerFor")) == null ? string.Empty : (row.Field<string>("BrokerFor")),
PeriodCollection = (row.Field<string>("PeriodCollection")) == null ? string.Empty : (row.Field<string>("PeriodCollection")),
boolIgnoreValue = (row.Field<string>("IgnoreValue")) == null ? false : Convert.ToBoolean((row.Field<string>("IgnoreValue"))),
IgnoreData = (!QCCommentstmp.Tables[0].Columns.Contains("IgnoreData") ? string.Empty : (row.Field<string>("IgnoreData") == null ? string.Empty : row.Field<string>("IgnoreData")))
}).ToList();
if (QCCommentlist != null)
{
foreach (var comment in QCCommentlist)
{
string section = comment.SectionFor;
string li = comment.LiFor;
string broker = comment.BrokerFor;
string period = comment.PeriodCollection;
string strQCPeriodValue = "";
if (comment.boolIgnoreValue && period.Trim() != "")
{
var QcViewColumnName = QCViewAlltmp.Tables[0].Columns.Cast<DataColumn>().AsParallel()
.Where(x => x.ColumnName.Contains(period))
.Select(x => new { x.ColumnName }).FirstOrDefault();
if (QcViewColumnName != null)
{
period = QcViewColumnName.ColumnName;
if (period.Trim() != "")
{
var datarow = QCViewAlltmp.Tables[0].AsEnumerable().AsParallel()
.Where(row => row.Field<string>("GroupKey").Split('~')[0].ToUpper() == section.ToUpper()
&& row.Field<string>("GroupKey").Split('~')[1].ToUpper() == li.ToUpper()
&& row.Field<string>("Section ").ToUpper() == broker.ToUpper());
if (datarow != null && datarow.Count() > 0)
{
strQCPeriodValue = (datarow.FirstOrDefault()[period] != null ? datarow.FirstOrDefault()[period].ToString() : string.Empty);
if (strQCPeriodValue.Trim() != string.Empty)
{
comment.IgnoreData = strQCPeriodValue;
counter++;
}
}
}
}
}
}
}
SerializeQcComment(QCCommentlist);
toolTip1.Hide(this);
}
}
}
Loading data from XML file into a dataset.
If the ignoredata
field is there in QCCommentstmp
dataset table QCCommentstmp.Tables[0].Columns.Contains("IgnoreData")
then deserialize QCCommentstmp table data to list List<clsCommentPopup> QCCommentlist
.
Iterate in QCCommentlist
's data using a for
loop and finding data in QCViewAlltmp.Tables[0]
data table for each iteration.
When QCCommentlist
has 25000 data then I am iterating in all 25000 data and finding data in another data table. If data is found then I am updating data in the list. This process is getting very slow and the code is taking a long time to finish all the iteration and searching data in the data table.
Please review my code and tell me how to restructure my code, as a result, there will be the improvement in code execution speed.
If my approach is wrong then guide me with the right approach and also give me the relevant code which I can use in my above code, as a result, my routine will take minimum time to finish if I iterate in more than 25000 data. I'm looking for suggestions and better code to achieve the same task.
c#
c#
New contributor
New contributor
edited yesterday
Jamal♦
30.6k11121227
30.6k11121227
New contributor
asked 2 days ago
user197025user197025
42
42
New contributor
New contributor
2
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
2 days ago
$begingroup$
should i use parallel foreach instead of normal foreach to get better performance?
$endgroup$
– user197025
yesterday
add a comment |
2
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
2 days ago
$begingroup$
should i use parallel foreach instead of normal foreach to get better performance?
$endgroup$
– user197025
yesterday
2
2
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
2 days ago
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
2 days ago
$begingroup$
should i use parallel foreach instead of normal foreach to get better performance?
$endgroup$
– user197025
yesterday
$begingroup$
should i use parallel foreach instead of normal foreach to get better performance?
$endgroup$
– user197025
yesterday
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216990%2fiterating-in-a-list-of-data-and-search-data-in-another-datatable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
user197025 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216990%2fiterating-in-a-list-of-data-and-search-data-in-another-datatable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
$begingroup$
Break this up into smaller functions and find where you are spending the most time. This function is too complex.
$endgroup$
– pacmaninbw
2 days ago
$begingroup$
should i use parallel foreach instead of normal foreach to get better performance?
$endgroup$
– user197025
yesterday