public void BuildThreaded() { Console.Error.WriteLine("Building..."); SimpleTimer lTimer = new SimpleTimer(); if (DFAMatrixes.Count < 64) { Build(); } else { DFAMatrixBuilder lDFAMatrixBuilder1 = new DFAMatrixBuilder(DFAMatrixes, DFAMatrixes.Count / 3); Thread lThread1 = new Thread(new ThreadStart(lDFAMatrixBuilder1.Build)); lThread1.Start(); DFAMatrixBuilder lDFAMatrixBuilder2 = new DFAMatrixBuilder(DFAMatrixes, DFAMatrixes.Count / 2); Thread lThread2 = new Thread(new ThreadStart(lDFAMatrixBuilder2.Build)); lThread2.Start(); Build(); lThread1.Join(); lThread2.Join(); DFAMatrixes.Push(lDFAMatrixBuilder1.DFAMatrixes.Pop()); DFAMatrixes.Push(lDFAMatrixBuilder2.DFAMatrixes.Pop()); Build(); } Console.Error.WriteLine("Build Time: " + lTimer.SecondsElapsed.ToString() + " Seconds"); Console.Error.WriteLine("Nodes: " + GetMatrix().DFANodes.Count.ToString()); }
public PatternDetector(PatternCollection patterns) { PatternCollection = patterns; DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(patterns); DFAMatrix = lDFAMatrixBuilder.GetMatrix(); }
// temp. for testing static void MatrixCompileToFile() { PatternCollection lPatterns = new PatternCollection(); if (!lPatterns.Load(@"Patterns/fuseki9.db")) { Console.WriteLine("ERROR: Unable to load patterns"); return; } Console.WriteLine("STATUS: Loaded " + lPatterns.Count + " Patterns."); SimpleTimer lTimer = new SimpleTimer(); Console.WriteLine(lTimer.StartTime.ToString()); DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(); lDFAMatrixBuilder.Add(lPatterns); Console.WriteLine(DateTime.Now.ToString()); lDFAMatrixBuilder.BuildThreaded(); Console.WriteLine(DateTime.Now.ToString()); Console.WriteLine("Seconds: " + lTimer.SecondsElapsed.ToString()); MemFile lMemFile = new MemFile(); lMemFile.Write(lDFAMatrixBuilder.GetMatrix().ToString()); lMemFile.SaveFile(@"Patterns/fuseki9.cdb"); }
public void Add(PatternCollection patterns) { DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(DFAMatrix); lDFAMatrixBuilder.Add(patterns); PatternCollection.Add(patterns); DFAMatrix lDFAMatrix = lDFAMatrixBuilder.GetMatrix(); lock (this) { DFAMatrix = lDFAMatrix; } }
public void BuildThreaded() { Console.Error.WriteLine("Building..."); SimpleTimer lTimer = new SimpleTimer(); if (DFAMatrixes.Count < 64) Build(); else { DFAMatrixBuilder lDFAMatrixBuilder1 = new DFAMatrixBuilder(DFAMatrixes, DFAMatrixes.Count / 3); Thread lThread1 = new Thread(new ThreadStart(lDFAMatrixBuilder1.Build)); lThread1.Start(); DFAMatrixBuilder lDFAMatrixBuilder2 = new DFAMatrixBuilder(DFAMatrixes, DFAMatrixes.Count / 2); Thread lThread2 = new Thread(new ThreadStart(lDFAMatrixBuilder2.Build)); lThread2.Start(); Build(); lThread1.Join(); lThread2.Join(); DFAMatrixes.Push(lDFAMatrixBuilder1.DFAMatrixes.Pop()); DFAMatrixes.Push(lDFAMatrixBuilder2.DFAMatrixes.Pop()); Build(); } Console.Error.WriteLine("Build Time: " + lTimer.SecondsElapsed.ToString() + " Seconds"); Console.Error.WriteLine("Nodes: " + GetMatrix().DFANodes.Count.ToString()); }