Python
This is running too slow. I convert a VB program to C#. The VB program takes 2 minutes and the C# takes 26 minutes. I privacy reasons I can
not send the WriteHistory. It build a StringBuilder and has a switch statement. There are 1.7 million records.
Any ideas on this would be appreciated.
arep
public static void PrintHistory(SqlDataReader sourceReader, bool b)
{
using (StreamWriter sw = new StreamWriter(@"Extract\History.txt", b, Encoding.Default))
{
StringBuilder record = new StringBuilder();
while (sourceReader.Read())
{
record = Program.WriteHistory(sourceReader);
sw.WriteLine("{0}", record);
}
}
}
VulpesRank #55 · 29.2K reputationPosted Sep 20, 2012, 2:10 PM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 18, 2012, 2:44 PM EDT
However, I can see that the only thing that can possibly be executing slowly there is the Program.WriteHistory() method. So I'd concentrate your efforts on speeding that up.
A RepaskyRank #8,108 · 228 reputationPosted Sep 20, 2012, 1:12 PM EDT
public static string Getdate(string myBD) { DateTime myDate = DateTime.MinValue; CultureInfo myCulture = CultureInfo.CreateSpecificCulture("en-US"); DateTimeStyles myDateTimeStyle = DateTimeStyles.None; string dateParsingFormat = "yyyyMMdd"; DateTime.TryParseExact(myBD, dateParsingFormat, myCulture, myDateTimeStyle, out myDate); return myDate.ToString("MM/dd/yyyy"); } It is called from this. if (Convert.ToInt64(dr["eligibilityenddate"]) > 0) DisenrollDate = Getdate(dr["eligibilityenddate"].ToString()); else DisenrollDate = "";I did not write this method and I am still not sure why the program is running slow.
arep
A RepaskyRank #8,108 · 228 reputationPosted Sep 21, 2012, 6:15 AM EDT
arep
VulpesRank #55 · 29.2K reputationPosted Sep 21, 2012, 6:59 AM EDT
Consequently, the time taken to create the objects and the frequent GCs were slowing down the application.
Anyway, pleased to hear that it seems to have solved the problem :)