Timeline for How to optimize C# console application
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 20, 2013 at 12:54 | comment | added | Peter Kiss | Your solution will fail if your dictionary doesn't contains the key from the line. This is becouse the OP base solution is incorrect: the methods can be called separately but the second one is based on the first result (distinct words). | |
Nov 20, 2013 at 12:32 | comment | added | Seph |
@PeterKiss don't you see anything wrong with making a new instance of a regex for each and every distinct word? What about the startup time of that? You can use a single new Regex(AlphanumericWords, RegexOptions.Compiled); instead (see my answer) and then you only run a single regex command over each line once rather once for each unique word.
|
|
Nov 19, 2013 at 20:32 | comment | added | Peter Kiss | In this case compiling the regular expressions are incrasing startup time so grately that it would not worth doing it. | |
Nov 19, 2013 at 19:32 | comment | added | Jeff Vanzella | This would be more efficient if you compile your regex | |
Nov 17, 2013 at 16:31 | history | edited | Peter Kiss | CC BY-SA 3.0 |
+= operator was wrong in the code
|
Nov 17, 2013 at 16:31 | comment | added | Peter Kiss | @svick: the += is a typo. I'm using 15 becouse in the result set most of the time the matching count is below 10 but there are significant number of result count more then 10 with a few match. Yes ToList() can be more effective but it doesn't matter in this case much. | |
Nov 17, 2013 at 14:47 | comment | added | svick |
One more thing: ToList() tends to be faster than ToArray() (because it can make one less copy).
|
|
Nov 17, 2013 at 14:46 | comment | added | svick |
Why do you have wordsOut[j] += … ? wordsOut[j] = … would be much clearer. Also, why are initializing the list to 15? Why exactly that number?
|
|
Nov 17, 2013 at 14:33 | comment | added | nuclearpeace | This is awesome. Never tried sortedSet or AsParallel(), thanks! I will dig into your code | |
Nov 17, 2013 at 14:30 | vote | accept | nuclearpeace | ||
Nov 19, 2013 at 17:26 | |||||
Nov 17, 2013 at 14:02 | history | answered | Peter Kiss | CC BY-SA 3.0 |