Beispiel #1
0
        public static string RunParserInitBenchmark(string testAdd, int iterations,
                                                    string performanceFolder = "performance", bool useChecks = true, bool useMultiThreading = false,
                                                    int workSizeMultiplier   = 2)
        {
            //FLSetup setup = new FLSetup("FL_ParserProcess_Performance"+ testAdd, "resources/kernel", performanceFolder,
            //    useChecks, useMultiThreading, workSizeMultiplier);
            StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n");


            FLInstructionSet      iset         = null;
            BufferCreator         bc           = null;
            FLParser              parser       = null;
            FLProgramCheckBuilder checkBuilder = null;
            KernelDatabase        db           = new KernelDatabase(CLAPI.MainThread, "resources/kernel", DataVectorTypes.Uchar1);
            string key = "ParserInitPerformance";

            Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1);
            PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations, null,
                                                                                          (int its) =>
            {
                iset         = FLInstructionSet.CreateWithBuiltInTypes(db);
                bc           = BufferCreator.CreateWithBuiltInTypes();
                checkBuilder = FLProgramCheckBuilder.CreateDefaultCheckBuilder(iset, bc);
                parser       = new FLParser(iset, bc);
            }, null);

            logOut.AppendLine("\t" + result);
            Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1);
            return(logOut.ToString());
        }
Beispiel #2
0
        public static string RunProgramDeserializationBenchmark(string testAdd, List <string> files, int iterations,
                                                                string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false,
                                                                int workSizeMultiplier   = 2)
        {
            FLSetup setup = new FLSetup("FL_DeserializationProcess_Performance" + testAdd, "resources/kernel", performanceFolder,
                                        checkPipeline, useMultiThreading, workSizeMultiplier);


            StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n");

            MemoryStream dst = new MemoryStream();

            for (int i = 0; i < files.Count; i++)
            {
                SerializableFLProgram pr = setup.Parser.Process(new FLParserInput(files[i]));
                string key = "ProgramDeserializationPerformance+" + Path.GetFileNameWithoutExtension(files[i]) + "." +
                             i;
                FLSerializer.SaveProgram(dst, pr, setup.InstructionSet, new string[] { });
                Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1);

                PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations,
                                                                                              (int its) => dst.Position = 0,
                                                                                              (int its) => FLSerializer.LoadProgram(dst, setup.InstructionSet),
                                                                                              null);
                logOut.AppendLine("\t" + result);
                Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1);
                setup.WriteResult(result);
            }

            dst.Dispose();
            logOut.AppendLine();
            setup.WriteLog(logOut.ToString());
            setup.Dispose();
            return(logOut.ToString());
        }
Beispiel #3
0
        public static string RunParserProcessBenchmark(string testAdd, List <string> files, int iterations,
                                                       string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false,
                                                       int workSizeMultiplier   = 2)
        {
            FLSetup setup = new FLSetup("FL_ParserProcess_Performance" + testAdd, "resources/kernel", performanceFolder,
                                        checkPipeline, useMultiThreading, workSizeMultiplier);
            StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n");

            for (int i = 0; i < files.Count; i++)
            {
                string file = files[i];
                string key  = "ParserPerformance+" + Path.GetFileNameWithoutExtension(file) + "." + i;
                Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1);
                PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key,
                                                                                              iterations,
                                                                                              null,
                                                                                              (int its) => setup.Parser.Process(new FLParserInput(file)),
                                                                                              null);
                logOut.AppendLine("\t" + result);
                Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1);
                setup.WriteResult(result);
            }

            logOut.AppendLine();
            setup.WriteLog(logOut.ToString());
            setup.Dispose();
            return(logOut.ToString());
        }
Beispiel #4
0
        public static string RunDeserializedFLExecutionBenchmark(string testAdd, List <string> files, int iterations,
                                                                 string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false,
                                                                 int workSizeMultiplier   = 2)
        {
            FLSetup setup = new FLSetup("FL_DeserializedExecution_Performance" + testAdd, "resources/kernel", performanceFolder,
                                        checkPipeline, useMultiThreading, workSizeMultiplier);
            StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n");

            for (int i = 0; i < files.Count; i++)
            {
                Bitmap   bmp = null;
                FLBuffer buf = null;
                SerializableFLProgram parsedProgram = null;
                MemoryStream          ms            = new MemoryStream();
                FLProgram             program       = null;
                string key = "FLDeserializedExecutionPerformance+" + Path.GetFileNameWithoutExtension(files[i]) + "." +
                             i;

                Logger.Log(LogType.Log, $"------------------------Run {key} Starting------------------------", 1);

                parsedProgram = setup.Parser.Process(new FLParserInput(files[i]));
                FLSerializer.SaveProgram(ms, parsedProgram, setup.InstructionSet, new string[0]);

                ms.Position   = 0;
                parsedProgram = FLSerializer.LoadProgram(ms, setup.InstructionSet);

                ms.Dispose();
                PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations,
                                                                                              (int its) => //BeforeTest
                {
                    bmp     = new Bitmap(BITMAP_RESOLUTION, BITMAP_RESOLUTION);
                    buf     = new FLBuffer(CLAPI.MainThread, bmp, files[i]);
                    program = parsedProgram.Initialize(setup.InstructionSet);
                },
                                                                                              (int its) => program.Run(CLAPI.MainThread, buf, true),
                                                                                              (int its) => //After Test
                {
                    if (its == iterations - 1)
                    {
                        SaveOutput("deserialized-output", bmp, program, setup, files[i]);
                    }

                    program.FreeResources();
                    bmp.Dispose();
                    buf.Dispose();
                });
                logOut.AppendLine("\t" + result);

                Logger.Log(LogType.Log, $"------------------------Run {key} Finished------------------------", 1);
                setup.WriteResult(result);
            }

            logOut.AppendLine();
            setup.WriteLog(logOut.ToString());
            setup.Dispose();
            return(logOut.ToString());
        }
Beispiel #5
0
        private static string RunTest(string testName, Action test, int iterations)
        {
            StringBuilder logOut = new StringBuilder($"Performance Tests: {DateTime.Now:HH:mm:ss}\n");

            BenchmarkHelper.RunNumber = iterations;
            BenchmarkHelper helper = new BenchmarkHelper(testName);

            logOut.AppendLine("Running Iterations: " + iterations);


            logOut.AppendLine($"------------------------Run {testName} Starting------------------------");

            PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(testName, iterations,
                                                                                          null,
                                                                                          (int its) => { test(); },
                                                                                          null);
            logOut.AppendLine("\t" + result);
            logOut.AppendLine($"------------------------Run {testName} Finished------------------------");
            helper.WriteResult(result);
            return(logOut.ToString());
        }