示例#1
0
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            TotalStopwatch.Stop();
            Stopwatch.Stop();

            long grandTotalMilliseconds = TotalStopwatch.ElapsedMilliseconds;
            long resultMilliseconds     = Stopwatch.ElapsedMilliseconds;

            filterContext.RouteData.Values.TryGetValue(Controller, out object conName);
            filterContext.RouteData.Values.TryGetValue(Action, out object actName);
            string controllerName = conName as string ?? throw new Exception();
            string actionName     = actName as string ?? throw new Exception();

            Benchmarks.Add(new ActionResultBenchmark(
                               controllerName: controllerName,
                               actionName: actionName,
                               grandTotalMilliseconds: grandTotalMilliseconds,
                               actionMilliseconds: TempNum, // more accurate to compared to subtracting "grandTotal" and "result"
                               resultMilliseconds: resultMilliseconds));

            (bool hasSaved, string filePath, string resultMessage) = FileSystemRepository.SaveJsonFile(BenchmarkName, Benchmarks);

            if (!hasSaved)
            {
                throw new Exception($"Error - log file not saved ({filePath}): {resultMessage}");
            }
        }
示例#2
0
 /// <summary>
 ///		Añade la información de tiempo
 /// </summary>
 public void AddBenchmark(string message, TimeSpan elapsed, long records)
 {
     // Añade la información a la lista
     Benchmarks.Add(new JobBenchmarkModel
     {
         Job     = ActualStep?.Job?.Name,
         Step    = ActualStep?.Name,
         Title   = message,
         Elapsed = elapsed,
         Records = records
     }
                    );
     // Escribe la información
     WriteInfo($"Benchmark\t{message}\tElapsed: {elapsed:HH:mm:ss.ms}\tRecords: {records}");
 }
        public override void Refresh()
        {
            //tags
            var selectedTags = Tags
                               .Where(x => x.IsChecked)
                               .Select(x => x.Item)
                               .ToList();

            Tags.Clear();

            foreach (var checkItem in Context
                     .Tags
                     .OrderBy(x => x.Name)
                     .ToList()
                     .Select(x => new CheckListItem <Tag>(x, selectedTags.Contains(x))))
            {
                Tags.Add(checkItem);
            }

            //strategies
            var selectedStrats = Strategies
                                 .Where(x => x.IsChecked)
                                 .Select(x => x.Item)
                                 .ToList();

            Strategies.Clear();

            foreach (var checkItem in Context
                     .Strategies
                     .OrderBy(x => x.Name)
                     .ToList()
                     .Select(x => new CheckListItem <Strategy>(x, selectedStrats.Contains(x))))
            {
                Strategies.Add(checkItem);
            }

            //benchmarks
            Benchmarks.Clear();
            foreach (Benchmark b in Context.Benchmarks.OrderBy(x => x.Name))
            {
                Benchmarks.Add(b);
            }
        }
        public override void Refresh()
        {
            //tags
            var selectedTags = Tags
                               .Where(x => x.IsChecked)
                               .Select(x => x.Item)
                               .ToList();

            Tags.Clear();

            foreach (var checkItem in Context
                     .Tags
                     .OrderBy(x => x.Name)
                     .ToList()
                     .Select(x => new CheckListItem <Tag>(x, selectedTags.Contains(x))))
            {
                Tags.Add(checkItem);
            }

            //strategies
            var selectedStrats = Strategies
                                 .Where(x => x.IsChecked)
                                 .Select(x => x.Item)
                                 .ToList();

            Strategies.Clear();

            foreach (var checkItem in Context
                     .Strategies
                     .OrderBy(x => x.Name)
                     .ToList()
                     .Select(x => new CheckListItem <Strategy>(x, selectedStrats.Contains(x))))
            {
                Strategies.Add(checkItem);
            }

            //Instruments
            if (Instruments.Count == 0)
            {
                //on first load we want all instruments selected, otherwise remember previous selection
                foreach (var checkItem in Context
                         .Instruments
                         .OrderBy(x => x.Symbol)
                         .ToList()
                         .Select(x => new CheckListItem <Instrument>(x, true)))
                {
                    Instruments.Add(checkItem);
                }
            }
            else
            {
                var selectedInstruments = Instruments
                                          .Where(x => x.IsChecked)
                                          .Select(x => x.Item)
                                          .ToList();
                Instruments.Clear();

                foreach (var checkItem in Context
                         .Instruments
                         .OrderBy(x => x.Symbol)
                         .ToList()
                         .Select(x => new CheckListItem <Instrument>(x, selectedInstruments.Contains(x))))
                {
                    Instruments.Add(checkItem);
                }
            }

            //benchmarks
            Benchmarks.Clear();
            foreach (Benchmark b in Context.Benchmarks.OrderBy(x => x.Name))
            {
                Benchmarks.Add(b);
            }

            //backtest results from the external data source
            BacktestSeries.Clear();
            if (Datasourcer.ExternalDataSource.Connected)
            {
                BacktestSeries.AddRange(
                    Datasourcer
                    .ExternalDataSource
                    .GetBacktestSeries());
            }
        }
示例#5
0
 /// <summary>
 ///     Instatiates a benchmark from the name and functions and adds
 ///     it to the list.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="Function"></param>
 public void AddBenchmark(string name, Func <double> function)
 {
     Benchmarks.Add(new Benchmark(name, function));
 }