Exemplo n.º 1
0
        /// <summary>
        /// just the default comparison
        /// </summary>
        private static void EvaluateStandardSet()
        {
            try
            {
                var factory   = new MutexTokenFactory();
                var watch     = Stopwatch.StartNew();
                var evalModel = new EvaluationRunModel(TEST_SUITE_DIRECTORY);
                cLogger.DebugFormat("evaluation run finished in {0} ms", watch.ElapsedMilliseconds);
                new ListResultsExport().Run(evalModel);

                File.WriteAllLines(@"test\tokens\tok1.txt", factory.GetTokenWrapperListFromFile(@"test\tokens\main-01.c").GetDebugTokenStrings());
                File.WriteAllLines(@"test\tokens\tok2.txt", factory.GetTokenWrapperListFromFile(@"test\tokens\main-03.c").GetDebugTokenStrings());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            //if ("y" == decision)
            {
                new ComparisonExcelExport("comparisons").Run(
                    ComparisonHistoryModel.AllHistories);

                new RuntimeExcelExport("runtime").Run(
                    new[]
                {
                    new ComparisonHistoryModel("TPLV04-S01-02"),
                });
            }

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Done!");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        /// <summary>
        /// takes the two sources and performs the GST
        /// </summary>
        /// <param name="sourcePath1"></param>
        /// <param name="sourcePath2"></param>
        public ComparisonModel(string name, Int64 evalRunID, string sourcePath1, string sourcePath2)
        {
            Name            = name;
            EvaluationRunID = evalRunID;

            var  directory      = Path.GetDirectoryName(Path.GetFullPath(sourcePath1));
            bool tmplFileExists = File.Exists(Path.Combine(directory, "template.c"));

            var watch = Stopwatch.StartNew();

            var tmplFile = Directory.GetFiles(directory, "template.c").FirstOrDefault();
            var path1    = tmplFileExists ? TemplatingHelper.StripTemplateFromSourceFile(sourcePath1, tmplFile) : sourcePath1;
            var path2    = tmplFileExists ? TemplatingHelper.StripTemplateFromSourceFile(sourcePath2, tmplFile) : sourcePath2;
            var factory  = new MutexTokenFactory();
            var tokens1  = factory.GetTokenWrapperListFromFile(path1);
            var tokens2  = factory.GetTokenWrapperListFromFile(path2);


            cLogger.DebugFormat("TokenStream Length: {0} -- {1}", tokens1.Count(), tokens2.Count());
            var algo = new GSTAlgorithm <GSTToken <TokenWrapper> >(
                tokens1.ToGSTTokenList <TokenWrapper>(),
                tokens2.ToGSTTokenList <TokenWrapper>());

            algo.RunToCompletion();
            Result = algo.Similarity;

            Source1 = new SourceModel(Path.GetFileNameWithoutExtension(sourcePath1), factory.GetJoinedTokenString(tokens1));
            Source2 = new SourceModel(Path.GetFileNameWithoutExtension(sourcePath2), factory.GetJoinedTokenString(tokens2));
            SQLFacade.Instance.CreateComparison(name, Result, watch.ElapsedMilliseconds, evalRunID, Source1.ID, Source2.ID);
        }
Exemplo n.º 3
0
        private static GSTTokenList <GSTToken <TokenWrapper> > GetTokens(FileInfo file)
        {
            var factory = new MutexTokenFactory();
            var tokens  = factory.GetTokenWrapperListFromFile(file.FullName);

            return(tokens.ToGSTTokenList());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Compares the two files and returns the Similarity.
        /// Lexer used: MutexCLexer
        /// Algorithm used: HashingGSTAlgorithm (MML = 8)
        /// </summary>
        /// <param name="path1"></param>
        /// <param name="path2"></param>
        /// <returns></returns>
        public static Int32 CompareFiles(string path1, string path2)
        {
            var factory = new MutexTokenFactory();

            var tokens1 = factory.GetTokenWrapperListFromFile(path1);
            var tokens2 = factory.GetTokenWrapperListFromFile(path2);

            var algo = new HashingGSTAlgorithm <GSTToken <TokenWrapper> >(
                tokens1.ToGSTTokenList <TokenWrapper>(),
                tokens2.ToGSTTokenList <TokenWrapper>())
            {
                MinimumMatchLength = 8
            };

            algo.RunToCompletion();


            return(algo.Similarity);
        }