Ejemplo n.º 1
0
 public void Check(MatcherReport report)
 {
     if (report.Time.Prepare > Prepare)
     {
         throw new FailedMutationException("Probe indexing time above limit: {0}ms", Convert.ToInt32(report.Time.Prepare * 1000));
     }
     if (report.Time.Matching > Matching)
     {
         throw new FailedMutationException("Matching pair time above limit: {0}us", Convert.ToInt32(report.Time.Matching * 1000000));
     }
     if (report.Time.NonMatching > NonMatching)
     {
         throw new FailedMutationException("Non-matching pair time above limit: {0}us", Convert.ToInt32(report.Time.NonMatching * 1000000));
     }
 }
Ejemplo n.º 2
0
        void RunMatcherBenchmark()
        {
#if !MONO
            if (Options.RenderGraph)
            {
                AccuracyStatistics.GraphDrawer = (curve, file) => { WpfIO.Save(RocGraph.Render(curve), file); }
            }
            ;
#endif

            string dbPath = Path.Combine("Extractor", "Templates.dat");
            if (File.Exists(dbPath))
            {
                TestDatabase.Load(dbPath);
            }
            else
            {
                RunExtractorBenchmark();
            }

            Console.WriteLine("Running matcher benchmark");
            MatcherReport report = MatcherBenchmark.Run();
            Console.WriteLine("Saving matcher report");
            report.Save("Matcher");
        }

        void RunOptimizer()
        {
            Optimizer.OnException += delegate(Exception e)
            {
                Console.WriteLine("Optimizer iteration failed: {0}", e.ToString());
            };
            Optimizer.Mutations.OnMutation += delegate(ParameterValue initial, ParameterValue mutated)
            {
                Console.WriteLine("Mutated {0}, {1} -> {2}", initial.FieldPath, initial.Value.Double, mutated.Value.Double);
            };
            Optimizer.NicheSlot.OnAccepted += message =>
            {
                Console.WriteLine("-----> Accepted: " + message);
                Optimizer.NicheSlot.Save("Optimizer");
            };
            Optimizer.NicheSlot.OnRejected += message =>
            {
                Console.WriteLine("Rejected: " + message);
            };
            Console.WriteLine("Running optimizer");
            Optimizer.Run();
        }
Ejemplo n.º 3
0
        public MatcherReport Run()
        {
            MatcherReport report = new MatcherReport();

            report.SetDatabaseCount(TestDatabase.Databases.Count);

            Stopwatch prepareTimer     = new Stopwatch();
            Stopwatch matchingTimer    = new Stopwatch();
            Stopwatch nonmatchingTimer = new Stopwatch();

            for (int databaseIndex = 0; databaseIndex < TestDatabase.Databases.Count; ++databaseIndex)
            {
                TestDatabase database = TestDatabase.Databases[databaseIndex];
                foreach (var template in database.AllIndexes)
                {
                    database[template].Template.MatcherCache = null;
                }
                database.MaxMatchingPerProbe    = MaxMatchingPerProbe;
                database.MaxNonMatchingPerProbe = MaxNonMatchingPerProbe;
                report.ScoreTables[databaseIndex].Initialize(database);
                foreach (DatabaseIndex probe in database.AllIndexes)
                {
                    RunPrepare(database[probe].Template, prepareTimer);
                    CollectMatches(database, database.GetMatchingPairs(probe), report.ScoreTables[databaseIndex], matchingTimer);
                    CollectMatches(database, database.GetNonMatchingPairs(probe), report.ScoreTables[databaseIndex], nonmatchingTimer);

                    if (prepareTimer.Elapsed.TotalSeconds + matchingTimer.Elapsed.TotalSeconds +
                        nonmatchingTimer.Elapsed.TotalSeconds > Timeout)
                    {
                        throw new TimeoutException("Timeout in matcher");
                    }
                }
            }

            report.Time.Prepare     = (float)prepareTimer.Elapsed.TotalSeconds / TestDatabase.FpCount;
            report.Time.Matching    = (float)matchingTimer.Elapsed.TotalSeconds / TestDatabase.GetMatchingPairCount();
            report.Time.NonMatching = (float)nonmatchingTimer.Elapsed.TotalSeconds / TestDatabase.GetNonMatchingPairCount();

            report.ComputeStatistics();

            return(report);
        }