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()); }
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()); }
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()); }