Ejemplo n.º 1
0
        protected override TestResult ExecuteTest(Spike.Scripting.Hosting.CSharp.Context ctx, string test)
        {
            var times = new List<long>();
            try
            {
                //Warmup run so we don't get hit by Spike.Scripting assembly JIT overhead
                ctx.ExecuteFile(test);

                for (int i = 0; i < Runs; i++)
                {
                    // Collect all garbage between runs
                    GC.Collect(2, GCCollectionMode.Forced);

                    // Run and time
                    var sw = Stopwatch.StartNew();
                    ctx.ExecuteFile(test);
                    sw.Stop();

                    times.Add(sw.ElapsedMilliseconds);
                }
            }
            catch (Exception ex)
            {
                return new TestResult { Error = ex.GetBaseException().Message, Tag = Tuple.Create(test, Enumerable.Repeat(-1L, Runs).ToArray()) };
            }

            return new TestResult { Score = GetScore(times), Tag = Tuple.Create(test, times.ToArray()) };
        }
Ejemplo n.º 2
0
        protected virtual TestResult ExecuteTest(Spike.Scripting.Hosting.CSharp.Context ctx, string test)
        {
            Stopwatch sw;

            try
            {
                sw = Stopwatch.StartNew();
                ctx.ExecuteFile(test);
                sw.Stop();
            }
            catch (Exception ex)
            {
                return new TestResult { Error = ex.GetBaseException().Message };
            }

            return new TestResult { Score = sw.ElapsedMilliseconds + "ms" };
        }