예제 #1
0
        public void Benchmark()
        {
            string benchScript = System.IO.File.ReadAllText(Program.BasePath + "examples/basic.nut");

            uint[][] parameters = new uint[][] {
                new uint[] { 1024, 1024 },
                new uint[] { 2048, 2048 },
                new uint[] { 4096, 4096 }
            };

            int totalPhases = 2 * parameters.Length;

            this.GGenThread = null;

            // the benchmark is starting right now
            if (this.benchmarkStatus == null)
            {
                this.benchmarkStatus = new BenchmarkStatus();

                this.WriteToConsole(Environment.NewLine + "Starting benchmark..." + Environment.NewLine);

                this.ExecuteScript(benchScript, false, parameters[0]);

                this.WriteToConsole("Starting reference script...");

                this.benchmarkForm.progressBar.Maximum = totalPhases;

                this.startTime = System.DateTime.Now.Ticks / 10000;
            }
            // the benchmark is already running
            else
            {
                Int64 time = System.DateTime.Now.Ticks / 10000 - this.startTime;

                // the benchmark script was executed
                if (this.benchmarkStatus.phase % 2 == 0)
                {
                    this.benchmarkStatus.thisBenchTime = time;

                    if (++this.benchmarkStatus.phase < totalPhases)
                    {
                        this.WriteToConsole("Starting benchmarked script...");
                        this.ExecuteScript(this.GetScript(), false, parameters[this.benchmarkStatus.phase / 2]);
                    }
                }
                // the user script was executed
                else
                {
                    this.benchmarkStatus.sumScores += (Double)time / (Double)this.benchmarkStatus.thisBenchTime;

                    if (++this.benchmarkStatus.phase < totalPhases)
                    {
                        this.WriteToConsole("Starting reference script...");
                        this.ExecuteScript(benchScript, false, parameters[this.benchmarkStatus.phase / 2]);
                    }
                }

                this.benchmarkForm.progressBar.Value = this.benchmarkStatus.phase;

                //this.benchmarkStatus.phaseStartTime = System.DateTime.Now.Ticks / 10000;

                // benchmark is finished
                if (this.benchmarkStatus.phase == totalPhases)
                {
                    Double score = Math.Round(this.benchmarkStatus.sumScores / parameters.Length, 2);

                    this.WriteToConsole("Benchmark finished with score " + score.ToString() + "x");

                    this.benchmarkStatus = null;

                    this.benchmarkForm.result.Text         = "Benchmark Score: " + score.ToString() + "x";
                    this.benchmarkForm.result.Visible      = true;
                    this.benchmarkForm.button.Text         = "Close";
                    this.benchmarkForm.progressBar.Visible = false;

                    this.ButtonsNoRunMode();
                }
            }
        }
예제 #2
0
        public void CancelBenchmark()
        {
            this.Terminate();

            this.benchmarkStatus = null;
        }
예제 #3
0
        public void Benchmark()
        {
            string benchScript = System.IO.File.ReadAllText(Program.BasePath + "examples/basic.nut");

            uint[][] parameters = new uint[][] {
                new uint[]{1024, 1024},
                new uint[]{2048, 2048},
                new uint[]{4096, 4096}
            };

            int totalPhases = 2 * parameters.Length;

            this.GGenThread = null;

            // the benchmark is starting right now
            if (this.benchmarkStatus == null)
            {
                this.benchmarkStatus = new BenchmarkStatus();

                this.WriteToConsole(Environment.NewLine + "Starting benchmark..." + Environment.NewLine);

                this.ExecuteScript(benchScript, false, parameters[0]);

                this.WriteToConsole("Starting reference script...");

                this.benchmarkForm.progressBar.Maximum = totalPhases;

                this.startTime = System.DateTime.Now.Ticks / 10000;
            }
            // the benchmark is already running
            else
            {
                Int64 time = System.DateTime.Now.Ticks / 10000 - this.startTime;

                // the benchmark script was executed
                if (this.benchmarkStatus.phase % 2 == 0)
                {
                    this.benchmarkStatus.thisBenchTime = time;

                    if (++this.benchmarkStatus.phase < totalPhases)
                    {
                        this.WriteToConsole("Starting benchmarked script...");
                        this.ExecuteScript(this.GetScript(), false, parameters[this.benchmarkStatus.phase / 2]);
                    }
                }
                // the user script was executed
                else
                {
                    this.benchmarkStatus.sumScores += (Double) time / (Double) this.benchmarkStatus.thisBenchTime;

                    if (++this.benchmarkStatus.phase < totalPhases)
                    {
                        this.WriteToConsole("Starting reference script...");
                        this.ExecuteScript(benchScript, false, parameters[this.benchmarkStatus.phase / 2]);
                    }
                }

                this.benchmarkForm.progressBar.Value = this.benchmarkStatus.phase;

                //this.benchmarkStatus.phaseStartTime = System.DateTime.Now.Ticks / 10000;

                // benchmark is finished
                if (this.benchmarkStatus.phase == totalPhases)
                {
                    Double score = Math.Round(this.benchmarkStatus.sumScores / parameters.Length, 2);

                    this.WriteToConsole("Benchmark finished with score " + score.ToString() + "x");

                    this.benchmarkStatus = null;

                    this.benchmarkForm.result.Text = "Benchmark Score: " + score.ToString() + "x";
                    this.benchmarkForm.result.Visible = true;
                    this.benchmarkForm.button.Text = "Close";
                    this.benchmarkForm.progressBar.Visible = false;

                    this.ButtonsNoRunMode();
                }
            }
        }
예제 #4
0
        public void BenchmarkFailed()
        {
            this.Invoke(new MethodInvoker(delegate()
            {
                this.WriteToConsole("Benchmark failed!" + Environment.NewLine);

                this.benchmarkStatus = null;

                if (this.benchmarkForm != null)
                {
                    this.benchmarkForm.result.Text = "Benchmark failed!";
                    this.benchmarkForm.result.ForeColor = System.Drawing.Color.Red;
                    this.benchmarkForm.result.Visible = true;
                    this.benchmarkForm.button.Text = "Close";
                    this.benchmarkForm.progressBar.Visible = false;
                }

                this.ButtonsNoRunMode();
            }));
        }
예제 #5
0
        public void CancelBenchmark()
        {
            this.Terminate();

            this.benchmarkStatus = null;
        }
예제 #6
0
 public Benchmark(string name, string sceneBehaviorName, BenchmarkStatus status)
 {
     Name = name;
     SceneBehaviorName = sceneBehaviorName;
     Status            = status;
 }