示例#1
0
        private static void SaveOutput(string subcategory, Bitmap bmp, FLProgram program, FLSetup setup, string file)
        {
            FLBuffer outP = program.GetActiveBuffer(false);

            CLAPI.UpdateBitmap(CLAPI.MainThread, bmp, outP.Buffer);
            outP.Dispose();
            string p         = Path.GetFileNameWithoutExtension(file) + ".png";
            Stream bmpStream = setup.GetDataFileStream(Path.Combine(subcategory, p));

            bmp.Save(bmpStream, ImageFormat.Png);
            bmpStream.Close();
        }
示例#2
0
        public static string RunProgramSerializationBenchmark(string testAdd, List <string> files, int iterations,
                                                              string[] extraSteps      = null,
                                                              string performanceFolder = "performance", Type[] checkPipeline = null, bool useMultiThreading = false,
                                                              int workSizeMultiplier   = 2)
        {
            FLSetup setup = new FLSetup("FL_SerializationProcess_Performance" + testAdd, "resources/kernel", performanceFolder,
                                        checkPipeline, useMultiThreading, workSizeMultiplier);

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

            string[] steps = extraSteps ?? new string[0];

            for (int i = 0; i < files.Count; i++)
            {
                MemoryStream          dst = new MemoryStream();
                SerializableFLProgram pr  = setup.Parser.Process(new FLParserInput(files[i]));
                string key = "ProgramSerializationPerformance+" + Path.GetFileNameWithoutExtension(files[i]) + "." + i;


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

                PerformanceTester.PerformanceResult result = PerformanceTester.Tester.RunTest(key, iterations,
                                                                                              (int its) => dst.Position = 0,
                                                                                              (int its) => FLSerializer.SaveProgram(dst, pr, setup.InstructionSet, steps),
                                                                                              null);

                dst.Position = 0;
                Stream s = setup.GetDataFileStream(Path.Combine("serialized-scripts", key + ".flc"));
                dst.CopyTo(s);
                dst.Close();
                s.Close();
                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());
        }