Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CommandBehavior.SchemaOnly
Message
 
 
To
30/07/2013 14:32:00
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01579375
Message ID:
01579476
Views:
35
>Going from an iterative approach to an equivalent LINQ approach is rarely going to improve speed, and it may even slow it down due to the overhead involved. It does however allow you to easily make it parallel by adding an AsParallel() after AsEnumerable(), which may improve the speed. I don't know if the data reader's GetFieldType method is thread-safe, so that may not be an option. You could also use the appropriate .Field< Type> instead of Convert if they are already the correct type.
>
>Of course you'll need to test if the LINQ statement is actually the slow part of your code.

By running Analysis I see this method to be slow (7.5%)
public static void PopulateFromSQML(this Dictionary<String, String> tDictionary, String tcSQML)
      {
         tDictionary.Clear();

         String pattern = @"<(?<field>[^/>]+)>(?<data>.*)</\k<field>>";

         MatchCollection matches = Regex.Matches(tcSQML, pattern, RegexOptions.Singleline);
         foreach (Match m in matches)
         {
            if (!tDictionary.ContainsKey(m.Groups["field"].ToString()))
               tDictionary.Add(m.Groups["field"].ToString(), m.Groups["data"].ToString().Trim());
         }
      }
And also one method where statements like
Byte originalPodBkType = bookingRow.Field<Byte>("podbktype"); 
take 1.9%
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform