void RunTest(bool readOnly, ScheduleMode schedule)
        {
            var system = World.GetOrCreateSystem <PerfTestSystem>();
            var name   = (readOnly ? "ReadOnly" : "Write") + "_" + schedule.ToString();

            Measure.Method(() =>
            {
                system.ReadOnly = false;
                system.Schedule = schedule;
                system.Update();
            })
            .SampleGroup(name)
            .MeasurementCount(5)
            .IterationsPerMeasurement(1)
            .Run();
        }
Ejemplo n.º 2
0
        private async Task ExecuteTask(ScheduledTaskWrapper taskWrapper, ScheduleMode mode, CancellationToken cancellationToken, params object[] args)
        {
            try
            {
                if (taskWrapper.Task is ScheduledTask)
                {
                    var task  = taskWrapper.Task as ScheduledTask;
                    var count = task.Pipeline.Count();
                    var msg   = $"Starting task {task.GetType().Name} [{mode.ToString()}]";
                    if (count > 1)
                    {
                        msg = $"{msg} (pipeline of {task.Pipeline.Count()} items)";
                        //log.LogInformation($"Starting task {task.GetType().Name} (pipeline of {task.Pipeline.Count()} items)");
                    }
                    log.Information(msg);
                }
                var sw = new Stopwatch();
                using (var sm = new SemaphoreSlim(1, 1))
                {
                    await sm.WaitAsync();

                    taskWrapper.IsRunning = true;
                    //taskWrapper.Task.SetMode()
                    sw.Start();
                    await taskWrapper.Task.ExecuteAsync(mode, cancellationToken, args);

                    sw.Stop();
                    taskWrapper.IsRunning = false;
                    log.Information($"Task {taskWrapper.Task.GetType().Name} completed in {sw.Elapsed}, will run next at {taskWrapper.NextRunTime.ToLocalTime().ToDefaultWithTime()}");
                }
            }
            catch (Exception ex)
            {
                var ex_args = new UnobservedTaskExceptionEventArgs(
                    ex as AggregateException ?? new AggregateException(ex));

                UnobservedTaskException?.Invoke(this, ex_args);

                if (!ex_args.Observed)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
 public async Task SetScheduleMode(string icd, ScheduleMode mode) => await _hubProxy.Invoke("SetScheduleMode", icd, mode.ToString());