public static ParsePerformanceData Parse(string directory, RootPackage rootPackage) { var ppd = new ParsePerformanceData { BaseDirectory = directory }; /* * 1) List all files * 2) Create module packages * 3) Enlist all file-package pairs in the queue * 4) Start parse threads * 5) Wait for all to join */ var tpd = new ThreadedDirectoryParser { baseDirectory = directory }; // 1), 2), 3) tpd.PrepareQueue(rootPackage); ppd.AmountFiles = tpd.queue.Count; var sw = new Stopwatch(); sw.Start(); // 4) var threads = new Thread[numThreads]; for (int i = 0; i < numThreads; i++) { var th = threads[i] = new Thread(tpd.ParseThread) { IsBackground = true, Priority = ThreadPriority.Lowest, Name = "Parser thread #" + i + " (" + directory + ")" }; th.Start(); } // 5) for (int i = 0; i < numThreads; i++) { if (threads[i].IsAlive) { threads[i].Join(10000); } } sw.Stop(); ppd.TotalDuration = sw.Elapsed.TotalSeconds; return(ppd); }
void parseDg(object o) { var tup = (Tuple <IEnumerable <string>, List <ParsePerformanceData> >)o; var parsedDirs = new List <string>(); var newRoot = new RootPackage(); foreach (var dir in tup.Item1) { parsedDirs.Add(dir); var dir_abs = dir; if (!Path.IsPathRooted(dir)) { dir_abs = Path.Combine(FallbackPath, dir_abs); } var ppd = ThreadedDirectoryParser.Parse(dir_abs, newRoot); if (ppd != null) { tup.Item2.Add(ppd); } } UfcsCache.Clear(); ParsedDirectories = parsedDirs; Root = newRoot; // For performance boost, pre-resolve the object class HandleObjectModule(GetModule("object")); if (FinishedParsing != null) { FinishedParsing(tup.Item2.ToArray()); } if (EnableUfcsCaching) { UfcsCache.Update(ParseCacheList.Create(this)); if (FinishedUfcsCaching != null) { FinishedUfcsCaching(); } } }
public static ParsePerformanceData Parse(string directory, RootPackage rootPackage) { var ppd = new ParsePerformanceData { BaseDirectory = directory }; /* * 1) List all files * 2) Create module packages * 3) Enlist all file-package pairs in the queue * 4) Start parse threads * 5) Wait for all to join */ var tpd = new ThreadedDirectoryParser { baseDirectory = directory }; // 1), 2), 3) tpd.PrepareQueue(rootPackage); ppd.AmountFiles = tpd.queue.Count; var sw = new Stopwatch(); sw.Start(); // 4) var threads = new Thread[numThreads]; for (int i = 0; i < numThreads; i++) { var th = threads[i] = new Thread(tpd.ParseThread) { IsBackground = true, Priority= ThreadPriority.Lowest, Name = "Parser thread #"+i+" ("+directory+")" }; th.Start(); } // 5) for (int i = 0; i < numThreads; i++) if (threads[i].IsAlive) threads[i].Join(10000); sw.Stop(); ppd.TotalDuration = sw.Elapsed.TotalSeconds; return ppd; }