Esempio n. 1
0
        static void Main(string[] args)
        {
            BenchmarkService     Service = new BenchmarkService();
            List <BenchmarkTask> Task    = new List <BenchmarkTask>
            {
                new BenchmarkTask {
                    Taskname = "Task1", Description = "ForLoop", Action = Task1, Iterations = 100, Quantity = 500
                },
                new BenchmarkTask {
                    Taskname = "Task2", Description = "WhileLoop", Action = Task2, Iterations = 100, Quantity = 500
                }
            };

            Service.CreateTask(Task);
            Console.WriteLine("Benchmark Starting");
            Service.StartBenchmark();
            Console.WriteLine("Benchmark Finished");
            Console.WriteLine("Benchmark Computing Result");
            Thread.Sleep(1000);
            Console.WriteLine("Benchmark Result \n");

            foreach (var item in Service.ComputedResult())
            {
                Console.WriteLine("Taskname: " + item.Taskname);
                Console.WriteLine("Description: " + item.Description);
                Console.WriteLine("Iterations: " + item.Iterations);
                Console.WriteLine("TotalExecution: " + item.TotalExecution);
                Console.WriteLine("TotalTimeElapsed: " + item.TotalElapsedTime + "ms");
                Console.WriteLine("AverageTimeElapsed: " + item.AverageElapsedTime + "ms\n");
            }
            Console.ReadLine();
        }
Esempio n. 2
0
        private void RunUnary(Channel channel, IInterarrivalTimer timer, BasicProfiler optionalProfiler)
        {
            if (optionalProfiler != null)
            {
                Profilers.SetForCurrentThread(optionalProfiler);
            }

            bool profilerReset = false;

            var client    = BenchmarkService.NewClient(channel);
            var request   = CreateSimpleRequest();
            var stopwatch = new Stopwatch();

            while (!stoppedCts.Token.IsCancellationRequested)
            {
                // after the first stats reset, also reset the profiler.
                if (optionalProfiler != null && !profilerReset && statsResetCount.Count > 0)
                {
                    optionalProfiler.Reset();
                    profilerReset = true;
                }

                stopwatch.Restart();
                client.UnaryCall(request);
                stopwatch.Stop();

                // spec requires data point in nanoseconds.
                histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos);

                timer.WaitForNext();
            }
        }
Esempio n. 3
0
        private static void Run(IConfigurationRoot config)
        {
            var protocol = config["protocol"] ?? string.Empty;

            if (!protocol.Equals("h2c", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("Only h2c is supported by C-core benchmark server.");
            }

            var address = config.CreateBindingAddress();

            Console.WriteLine($"Starting C-core server listening on {address.Host}:{address.Port}");

            Server server = new Server
            {
                Services =
                {
                    BenchmarkService.BindService(new BenchmarkServiceImpl())
                },
                Ports =
                {
                    // C-core benchmarks currently only support insecure (h2c)
                    { address.Host, address.Port, ServerCredentials.Insecure }
                }
            };

            server.Start();

            Console.WriteLine("Started!");
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
        /// <summary>
        /// Run the application.
        /// </summary>
        public override BoolMessageItem  Execute()
        {
            //<doc:example>
            // Example 1: Get a benchmark by running an action.
            BenchmarkResult result = Benchmark.Run(() => Console.WriteLine("Get benchmark using run method."));

            // Example 2: Get a benchmark by running a named action with a message.
            var result2 = Benchmark.Run("Example 2", "Running named benchmark", () => Console.WriteLine("Running example 2"));

            // Example 3: Run an action and report the benchmark data.
            Benchmark.Report("Example 3", "Reporting benchmark", (res) => Console.WriteLine(res.ToString()), () => Console.WriteLine("Running example 3"));
            Benchmark.Report("Example 3b", "Reporting benchmark", null, () => Console.WriteLine("Running example 3b"));

            // Example 4: Get instance of Benchmark service and run multiple reports on it.
            Benchmark.Get("Example 4", "testing", null, (bm) =>
            {
                bm.Run("4a", "testing", () => Console.WriteLine("Running 4a"));
                bm.Run("4b", "testing", () => Console.WriteLine("Running 4b"));
                bm.Run("4c", "testing", () => Console.WriteLine("Running 4c"));
            });

            // Example 5: Get instace of benchmark service manually.
            var bm2 = new BenchmarkService("Example 5", "manually instance of bm service", null);

            bm2.Run(() => Console.WriteLine("Running example 5"));

            //</doc:example>
            return(BoolMessageItem.True);
        }
Esempio n. 5
0
        private async Task RunStreamingPingPongAsync(Channel channel, IInterarrivalTimer timer)
        {
            var client    = BenchmarkService.NewClient(channel);
            var request   = CreateSimpleRequest();
            var stopwatch = new Stopwatch();

            using (var call = client.StreamingCall())
            {
                while (!stoppedCts.Token.IsCancellationRequested)
                {
                    stopwatch.Restart();
                    await call.RequestStream.WriteAsync(request);

                    await call.ResponseStream.MoveNext();

                    stopwatch.Stop();

                    // spec requires data point in nanoseconds.
                    histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos);

                    await timer.WaitForNextAsync();
                }

                // finish the streaming call
                await call.RequestStream.CompleteAsync();

                Assert.IsFalse(await call.ResponseStream.MoveNext());
            }
        }
Esempio n. 6
0
        public Benchmarks(DataInitFixture fixture, ITestOutputHelper output)
        {
            //Initialize the output
            this._output = output;

            //Initialize DbContext in memory
            this._fixture = fixture;

            var builder =
                new ConfigurationBuilder()
                .AddJsonFile("testsettings.json")
                .AddEnvironmentVariables();

            Configuration = builder.Build();

            this._apibaseUrl = Configuration["AAD:Url"];

            //Create the all services
            _svcBenchmark      = new BenchmarkService(_fixture.Context);
            _svcAuth           = new AuthService(_fixture.Context);
            _svcMsg            = new MessageService(_fixture.Context);
            _svcPlayerResponse = new PlayerResponseService(_fixture.Context);
            _svcPractice       = new PracticeService(_fixture.Context);
            _svcQuestionnaire  = new QuestionnaireService(_fixture.Context);
            _svcSession        = new SessionService(_fixture.Context);
            _svcCognitive      = new CognitiveService(_fixture.Context);
            _svcDrill          = new DrillService(_fixture.Context);
            _svcSettings       = new SettingsService(_fixture.Context);
            _svcTeam           = new TeamService(_fixture.Context);
            _svcWorkout        = new WorkoutService(_fixture.Context);
        }
Esempio n. 7
0
        public MeasurementResult Measure()
        {
            var binding = _scheme == "net.tcp"
                ? (Binding) new NetTcpBinding()
                : new NetNamedPipeBinding();

            var benchmarkService = new BenchmarkService();
            var serviceHost      = new ServiceHost(benchmarkService, new Uri($"{_scheme}://127.0.0.1/Benchmarks"));

            serviceHost.AddServiceEndpoint(typeof(IBenchmarkService), binding, $"{_scheme}://127.0.0.1/Benchmarks");
            serviceHost.Open();

            var channelFactory = new DuplexChannelFactory <IBenchmarkService>(new InstanceContext(new BenchmarkCallback()), binding, new EndpointAddress($"{_scheme}://127.0.0.1/Benchmarks"));
            var channel        = channelFactory.CreateChannel();

            var result = MeasurementResult.Measure($"WCF: One-way calls with {_scheme}", () =>
            {
                for (var i = 0; i < _iterations; i++)
                {
                    channel.OneWayCall();
                }
            });

            ((IClientChannel)channel).Close();

            serviceHost.Close();

            return(result);
        }
Esempio n. 8
0
        public static async Task <ResultValue> GetSystemData(Dictionary <string, object> parameterDictionary)
        {
            var systemDataResult = new ResultValue();

            try
            {
                var dateType  = parameterDictionary["DateType"].ToString();
                var brandType = parameterDictionary["BrandType"].ToString();
                var category  = parameterDictionary["Category"] == null ? string.Empty : parameterDictionary["Category"].ToString();
                var category1 = string.Empty;
                var category2 = string.Empty;
                if (!string.IsNullOrEmpty(category))
                {
                    var categorys = category.Split(new[] { "*" }, StringSplitOptions.RemoveEmptyEntries);
                    category1 = categorys[0];
                    category2 = categorys.Count() == 2 ? categorys[1] : string.Empty;
                }

                var dimensions         = parameterDictionary["Dimensions"] == null ? string.Empty : parameterDictionary["Dimensions"].ToString();
                var metrics            = parameterDictionary["Metrics"].ToString();
                var benchmarkDataValue = await BenchmarkService.GetBenchmarkDatas(dateType, brandType, category1, category2, dimensions, metrics);

                if (((RestResponseBase)(benchmarkDataValue)).StatusCode == HttpStatusCode.OK) //200
                {
                    systemDataResult = benchmarkDataValue.Data;
                }
                else if (((RestResponseBase)(benchmarkDataValue)).StatusCode == HttpStatusCode.NotFound) //404
                {
                    ShowMessage.Show("访问404错误");
                }
                else if ((int)benchmarkDataValue.StatusCode == 422)
                {
                    ShowMessage.Show("访问422错误");
                }
                else if (((RestResponseBase)(benchmarkDataValue)).StatusCode == HttpStatusCode.InternalServerError) //500
                {
                    ShowMessage.Show("访问500错误");
                }
                else
                {
                    ShowMessage.Show("未知错误");
                }
            }
            catch (Exception ex)
            {
                ShowMessage.Show("加载数据出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to GetSystemData", ex);
            }
            finally
            {
                if (LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "GetSystemData", null);
                }
            }

            return(systemDataResult);
        }
Esempio n. 9
0
        public SyncUnaryClientRunner(Channel channel, int payloadSize, HistogramParams histogramParams)
        {
            this.channel     = Grpc.Core.Utils.Preconditions.CheckNotNull(channel);
            this.payloadSize = payloadSize;
            this.histogram   = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible);

            this.stoppedCts = new CancellationTokenSource();
            this.client     = BenchmarkService.NewClient(channel);
            this.runnerTask = Task.Factory.StartNew(Run, TaskCreationOptions.LongRunning);
        }
Esempio n. 10
0
        internal void UpdateBenchmarkFrameTimes(WorkUnitModel workUnitModel, WorkUnitModel newWorkUnitModel)
        {
            // current frame has already been recorded, increment to the next frame
            int nextFrame  = workUnitModel.FramesComplete + 1;
            int count      = newWorkUnitModel.FramesComplete - workUnitModel.FramesComplete;
            var frameTimes = GetFrameTimes(newWorkUnitModel.WorkUnit, nextFrame, count);

            if (frameTimes.Count > 0)
            {
                var slotIdentifier      = newWorkUnitModel.SlotModel.SlotIdentifier;
                var benchmarkIdentifier = newWorkUnitModel.BenchmarkIdentifier;
                BenchmarkService.Update(slotIdentifier, benchmarkIdentifier, frameTimes);
            }
        }
Esempio n. 11
0
        public sealed override void Generate(IBenchmarksReportSource source)
        {
            var slotIdentifier = source.SlotIdentifier;
            var projectID      = GetProjectID(source);
            var protein        = GetProtein(projectID);
            var colors         = source.Colors;

            if (slotIdentifier is null || projectID is null || protein is null)
            {
                Result = null;
                return;
            }

            var benchmarks = SortBenchmarks(BenchmarkService.GetBenchmarks(slotIdentifier.Value, protein.ProjectNumber));

            var zg = CreateZedGraphControl();

            try
            {
                GraphPane pane = zg.GraphPane;

                // Create the bars for each benchmark
                int    i        = 0;
                double yMaximum = 0.0;
                foreach (ProteinBenchmark benchmark in benchmarks)
                {
                    var yPoints = GetYPoints(protein, benchmark);
                    foreach (var y in yPoints)
                    {
                        yMaximum = Math.Max(yMaximum, y);
                    }

                    string label = GetSlotNameAndProcessor(benchmark, protein);
                    var    color = GetNextColor(i++, colors);
                    AddBar(pane, label, yPoints, color);
                }

                ConfigureXAxis(pane.XAxis, protein);
                ConfigureYAxis(pane.YAxis, yMaximum);

                FillChart(pane.Chart);
                FillGraphPane(pane);
            }
            finally
            {
                zg.AxisChange();
            }

            Result = zg;
        }
Esempio n. 12
0
        /// <summary>
        /// Creates a started server runner.
        /// </summary>
        public static IServerRunner CreateStarted(ServerConfig config)
        {
            Grpc.Core.Utils.Preconditions.CheckArgument(config.ServerType == ServerType.ASYNC_SERVER);
            var credentials = config.SecurityParams != null?TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure;

            // TODO: qps_driver needs to setup payload properly...
            int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0;
            var server       = new Server
            {
                Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) },
                Ports    = { new ServerPort(config.Host, config.Port, credentials) }
            };

            server.Start();
            return(new ServerRunnerImpl(server));
        }
Esempio n. 13
0
        private static void TestServices()
        {
            RoleService.Init();
            UserService.Init();
            CountryService.Init();
            LanguageService.Init();
            AvgAmountService.Init();
            CountryAdditionalHourService.Init();
            ColouringService.Init();
            FeastService.Init();
            AbsenceService.Init();
            WorkingModelService.Init();
            YearlyWorkingDayService.Init();
            EmployeeService.Init();
            EmployeeRelationService.Init();
            EmployeeContractService.Init();
            LongTimeAbsenceService.Init();
            EmployeeLongTimeAbsenceService.Init();
            StoreService.Init();
            WGRService.Init();
            HWGRService.Init();
            WorldService.Init();
            StoreToWorldService.Init();
            WorldToHWGRService.Init();
            HwgrToWgrService.Init();
            StoreWorkingTimeService.Init();
            StoreAdditionalHourService.Init();
            BufferHoursService.Init();
            BenchmarkService.Init();
            TrendCorrectionService.Init();
            PersonMinMaxService.Init();
            RegionService.Init();

            AbsenceTimePlanningService.Init();
            AbsenceTimeRecordingService.Init();
            WorkingTimePlanningService.Init();
            WorkingTimeRecordingService.Init();
            EmployeeTimeService.Init();
            AvgWorkingDaysInWeekService.Init();
            EmployeeDayStatePlanningService.Init();
            EmployeeDayStateRecordingService.Init();
            EmployeeWeekTimePlanningService.Init();
            EmployeeWeekTimeRecordingService.Init();
            EmployeePlanningWorkingModelService.Init();
            EmployeeRecordingWorkingModelService.Init();
        }
Esempio n. 14
0
        /// <summary>
        /// Creates a started server runner.
        /// </summary>
        public static IServerRunner CreateStarted(ServerConfig config)
        {
            Logger.Debug("ServerConfig: {0}", config);
            var credentials = config.SecurityParams != null?TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure;

            if (config.AsyncServerThreads != 0)
            {
                Logger.Warning("ServerConfig.AsyncServerThreads is not supported for C#. Ignoring the value");
            }
            if (config.CoreLimit != 0)
            {
                Logger.Warning("ServerConfig.CoreLimit is not supported for C#. Ignoring the value");
            }
            if (config.CoreList.Count > 0)
            {
                Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value");
            }

            ServerServiceDefinition service = null;

            if (config.ServerType == ServerType.AsyncServer)
            {
                GrpcPreconditions.CheckArgument(config.PayloadConfig == null,
                                                "ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server.");
                service = BenchmarkService.BindService(new BenchmarkServiceImpl());
            }
            else if (config.ServerType == ServerType.AsyncGenericServer)
            {
                var genericService = new GenericServiceImpl(config.PayloadConfig.BytebufParams.RespSize);
                service = GenericService.BindHandler(genericService.StreamingCall);
            }
            else
            {
                throw new ArgumentException("Unsupported ServerType");
            }

            var channelOptions = new List <ChannelOption>(config.ChannelArgs.Select((arg) => arg.ToChannelOption()));
            var server         = new Server(channelOptions)
            {
                Services = { service },
                Ports    = { new ServerPort("[::]", config.Port, credentials) }
            };

            server.Start();
            return(new ServerRunnerImpl(server));
        }
Esempio n. 15
0
        public override void Generate(IBenchmarksReportSource source)
        {
            var benchmarkText = new List <string>();

            var slotIdentifier = source.SlotIdentifier;
            var projects       = source.Projects;

            if (slotIdentifier is null || projects.Count == 0)
            {
                Result = benchmarkText;
                return;
            }

            string numberFormat     = NumberFormat.Get(Preferences.Get <int>(Preference.DecimalPlaces));
            var    bonusCalculation = Preferences.Get <BonusCalculation>(Preference.BonusCalculation);
            bool   calculateBonus   = bonusCalculation != BonusCalculation.None;

            foreach (var projectID in projects)
            {
                var protein = ProteinService.Get(projectID);
                if (protein is null)
                {
                    benchmarkText.Add(String.Format(CultureInfo.InvariantCulture, " Project ID: {0} Not Found", projectID));
                    benchmarkText.AddRange(Enumerable.Repeat(String.Empty, 2));
                    continue;
                }

                var benchmarks = BenchmarkService.GetBenchmarks(slotIdentifier.Value, protein.ProjectNumber)
                                 .OrderBy(x => x.SlotIdentifier.Name)
                                 .ThenBy(x => x.Threads);

                benchmarkText
                .AddRange(EnumerateProjectInformation(protein)
                          .Concat(Enumerable.Repeat(String.Empty, 2)));

                foreach (var b in benchmarks)
                {
                    benchmarkText
                    .AddRange(EnumerateBenchmarkInformation(protein, b, numberFormat, calculateBonus)
                              .Concat(EnumerateSlotInformation(FindRunningSlot(b), numberFormat, bonusCalculation))
                              .Concat(Enumerable.Repeat(String.Empty, 2)));
                }
            }

            Result = benchmarkText;
        }
Esempio n. 16
0
        private void RunUnary(Channel channel, IInterarrivalTimer timer)
        {
            var client    = BenchmarkService.NewClient(channel);
            var request   = CreateSimpleRequest();
            var stopwatch = new Stopwatch();

            while (!stoppedCts.Token.IsCancellationRequested)
            {
                stopwatch.Restart();
                client.UnaryCall(request);
                stopwatch.Stop();

                // spec requires data point in nanoseconds.
                histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos);

                timer.WaitForNext();
            }
        }
Esempio n. 17
0
        public static async Task <Dictionary <string, string> > GetBaseData(Dictionary <string, object> parameterDictionary = null)
        {
            var baseDataDictionary = new Dictionary <string, string>();

            try
            {
                var baseDataResult = await BenchmarkService.GetBenchmarkBaseDatas();

                if (((RestResponseBase)(baseDataResult)).StatusCode == HttpStatusCode.OK) //200
                {
                    baseDataDictionary = baseDataResult.Data.ToDictionary(d => d.Key, d => d.Value);
                }
                else if (((RestResponseBase)(baseDataResult)).StatusCode == HttpStatusCode.NotFound) //404
                {
                    ShowMessage.Show("访问404错误");
                }
                else if ((int)baseDataResult.StatusCode == 422)
                {
                    ShowMessage.Show("访问422错误");
                }
                else if (((RestResponseBase)(baseDataResult)).StatusCode == HttpStatusCode.InternalServerError) //500
                {
                    ShowMessage.Show("访问500错误");
                }
                else
                {
                    ShowMessage.Show("未知错误");
                }
            }
            catch (Exception ex)
            {
                ShowMessage.Show("加载数据出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to GetBaseData", ex);
            }
            finally
            {
                if (LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "GetBaseData", null);
                }
            }

            return(baseDataDictionary);
        }
Esempio n. 18
0
        public static async Task <ResultValue> GetDataByCategorys1(string categorys1)
        {
            var categorys2ListResult = new ResultValue();

            try
            {
                var benchmarkTypeDataValue = await BenchmarkService.GetCategorys2Datas(categorys1);

                if (((RestResponseBase)(benchmarkTypeDataValue)).StatusCode == HttpStatusCode.OK) //200
                {
                    categorys2ListResult = benchmarkTypeDataValue.Data;
                }
                else if (((RestResponseBase)(benchmarkTypeDataValue)).StatusCode == HttpStatusCode.NotFound) //404
                {
                    ShowMessage.Show("访问404错误");
                }
                else if ((int)benchmarkTypeDataValue.StatusCode == 422)
                {
                    ShowMessage.Show("访问422错误");
                }
                else if (((RestResponseBase)(benchmarkTypeDataValue)).StatusCode == HttpStatusCode.InternalServerError) //500
                {
                    ShowMessage.Show("访问500错误");
                }
                else
                {
                    ShowMessage.Show("未知错误");
                }
            }
            catch (Exception ex)
            {
                ShowMessage.Show("加载数据出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to GetDataByType", ex);
            }
            finally
            {
                if (LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "GetDataByType", null);
                }
            }

            return(categorys2ListResult);
        }
Esempio n. 19
0
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .AddJsonFile("hosting.json", optional: true)
                         .AddEnvironmentVariables(prefix: "ASPNETCORE_")
                         .AddCommandLine(args)
                         .Build();

            var protocol = config["protocol"] ?? string.Empty;

            if (!protocol.Equals("h2c", StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("Only h2c is supported by C-core benchmark server.");
            }

            var endpoint = config.CreateIPEndPoint();
            var host     = endpoint.Address.ToString();

            Console.WriteLine($"Starting C-core server listening on {host}:{endpoint.Port}");

            Server server = new Server
            {
                Services =
                {
                    BenchmarkService.BindService(new BenchmarkServiceImpl())
                },
                Ports =
                {
                    // C-core benchmarks currently only support insecure (h2c)
                    { host, endpoint.Port, ServerCredentials.Insecure }
                }
            };

            server.Start();

            Console.WriteLine("Started!");
            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
        public StoreWorldEstimateInfoBuilder(IStoreService storeservice,
                                             IStoreToWorldService storeworldservice
                                             )
        {
            if (storeservice == null)
            {
                throw new ArgumentNullException();
            }

            if (storeworldservice == null)
            {
                throw new ArgumentNullException();
            }

            _storeservice        = (StoreService)storeservice;
            _storetoworldservice = (StoreToWorldService)storeworldservice;

            _personminmaxservice = (PersonMinMaxService)_storetoworldservice.PersonMinMaxService;
            _bufferhoursservice  = (BufferHoursService)_storetoworldservice.BufferHoursService;
            _benchmarkservice    = (BenchmarkService)_storeservice.BenchmarkService;
            _avgamountservice    = (AvgAmountService)_storetoworldservice.AvgAmountService;
        }
Esempio n. 21
0
        internal void UpdateBenchmarkData(UnitInfoModel currentUnitInfo, UnitInfoModel[] parsedUnits, int currentUnitIndex)
        {
            var foundCurrent   = false;
            var processUpdates = false;

            foreach (int index in UnitIndexIterator(currentUnitIndex, parsedUnits.Length))
            {
                var unitInfoModel = parsedUnits[index];

                // If Current has not been found, check the nextUnitIndex
                // or try to match the Current Project and Raw Download Time
                if (unitInfoModel != null && processUpdates == false && (index == currentUnitIndex || currentUnitInfo.UnitInfoData.IsSameUnitAs(unitInfoModel.UnitInfoData)))
                {
                    foundCurrent   = true;
                    processUpdates = true;
                }

                if (processUpdates)
                {
                    int previousFramesComplete = 0;
                    if (foundCurrent)
                    {
                        // current frame has already been recorded, increment to the next frame
                        previousFramesComplete = currentUnitInfo.FramesComplete + 1;
                        foundCurrent           = false;
                    }

                    // Even though the current UnitInfoLogic has been found in the parsed UnitInfoLogic array doesn't
                    // mean that all entries in the array will be present.  See TestFiles\SMP_12\FAHlog.txt.
                    if (unitInfoModel != null)
                    {
                        // Update benchmarks
                        BenchmarkService.UpdateData(unitInfoModel.UnitInfoData, previousFramesComplete, unitInfoModel.FramesComplete);
                        // Update history database
                        UpdateUnitInfoDatabase(unitInfoModel);
                    }
                }
            }
        }
        public StoreWorldEstimateInfoBuilder(IStoreService storeservice,
                                             IStoreToWorldService storeworldservice
                                            )
        {
            if (storeservice == null)
            {
                throw new ArgumentNullException();
            }

            if (storeworldservice == null)
            {
                throw new ArgumentNullException();
            }

            _storeservice = (StoreService)storeservice;
            _storetoworldservice = (StoreToWorldService)storeworldservice;

            _personminmaxservice = (PersonMinMaxService)_storetoworldservice.PersonMinMaxService;
            _bufferhoursservice = (BufferHoursService)_storetoworldservice.BufferHoursService;
            _benchmarkservice = (BenchmarkService)_storeservice.BenchmarkService;
            _avgamountservice = (AvgAmountService)_storetoworldservice.AvgAmountService;
        }
Esempio n. 23
0
 internal void UpdateBenchmarkData(UnitInfoModel currentUnitInfo, IEnumerable <UnitInfoModel> parsedUnits, int currentUnitIndex)
 {
     foreach (var unitInfoModel in parsedUnits.Where(x => x != null))
     {
         if (currentUnitInfo.UnitInfoData.IsSameUnitAs(unitInfoModel.UnitInfoData))
         {
             // found the current unit
             // current frame has already been recorded, increment to the next frame
             int previousFramesComplete = currentUnitInfo.FramesComplete + 1;
             // Update benchmarks
             BenchmarkService.UpdateData(unitInfoModel.UnitInfoData, previousFramesComplete, unitInfoModel.FramesComplete);
         }
         // Update history database
         if (unitInfoModel.UnitInfoData.UnitResult != WorkUnitResult.Unknown)
         {
             UpdateUnitInfoDatabase(unitInfoModel);
         }
         //// used when there is no currentUnitInfo
         //else if (unitInfoLogic.UnitInfoData.QueueIndex == currentUnitIndex)
         //{
         //   BenchmarkCollection.UpdateData(unitInfoLogic.UnitInfoData, 0, unitInfoLogic.FramesComplete);
         //}
     }
 }
Esempio n. 24
0
 public BenchmarkController(BenchmarkService benchmarkService)
 {
     _benchmarkService = benchmarkService;
 }
Esempio n. 25
0
        public static void InitServices()
        {
            // when connection is lost, it seems old references are no longer valid
            _ImportParam.CountryService  = null;
            _ImportParam.EmployeeService = null;
            _ImportParam.RegionService   = null;
            _ImportParam.StoreService    = null;
            _UserService     = null;
            _CountryService  = null;
            _LanguageService = null;
            _EmployeeService = null;
            _StoreService    = null;
            _RegionService   = null;
            _AuthService     = null;
            _RoleService     = null;

            RoleService.Init();
            UserService.Init();
            CountryService.Init();
            LanguageService.Init();
            AvgAmountService.Init();
            CountryAdditionalHourService.Init();
            ColouringService.Init();
            FeastService.Init();
            AbsenceService.Init();
            WorkingModelService.Init();
            YearlyWorkingDayService.Init();
            EmployeeService.Init();
            EmployeeRelationService.Init();
            EmployeeAllInService.Init();
            EmployeeContractService.Init();
            LongTimeAbsenceService.Init();
            EmployeeLongTimeAbsenceService.Init();
            StoreService.Init();
            WGRService.Init();
            HWGRService.Init();
            WorldService.Init();
            StoreToWorldService.Init();
            WorldToHWGRService.Init();
            HwgrToWgrService.Init();
            StoreWorkingTimeService.Init();
            StoreAdditionalHourService.Init();
            BufferHoursService.Init();
            BufferHourAvailableService.Init();
            BenchmarkService.Init();
            TrendCorrectionService.Init();
            PersonMinMaxService.Init();
            RegionService.Init();

            AbsenceTimePlanningService.Init();
            AbsenceTimeRecordingService.Init();
            WorkingTimePlanningService.Init();
            WorkingTimeRecordingService.Init();
            EmployeeTimeService.Init();
            AvgWorkingDaysInWeekService.Init();
            EmployeeDayStatePlanningService.Init();
            EmployeeDayStateRecordingService.Init();
            EmployeeWeekTimePlanningService.Init();
            EmployeeWeekTimeRecordingService.Init();
            EmployeePlanningWorkingModelService.Init();
            EmployeeRecordingWorkingModelService.Init();
            EmployeeHolidaysInfoService.Init();

            _ImportParam.CountryService  = CountryService;
            _ImportParam.EmployeeService = EmployeeService;
            _ImportParam.RegionService   = RegionService;
            _ImportParam.StoreService    = StoreService;
        }
Esempio n. 26
0
        private TimeSpan GetBenchmarkAverageFrameTimeOrDefault(UnitInfo unitInfo)
        {
            var benchmark = BenchmarkService.GetBenchmark(unitInfo);

            return(benchmark != null ? benchmark.AverageFrameTime : TimeSpan.Zero);
        }
Esempio n. 27
0
        public override void Generate(IBenchmarksReportSource source)
        {
            var slotIdentifier = source.SlotIdentifier;
            var projects       = source.Projects;
            var colors         = source.Colors;

            if (slotIdentifier is null || projects.Count == 0)
            {
                Result = null;
                return;
            }

            var benchmarks = BenchmarkService.GetBenchmarks(slotIdentifier.Value, projects)
                             .OrderBy(x => x.SlotIdentifier.Name)
                             .ThenBy(x => x.Threads)
                             .ToList();

            if (benchmarks.Count == 0)
            {
                Result = null;
                return;
            }

            var projectToXAxisOrdinal = BuildProjectToXAxisOrdinal(benchmarks);

            var zg = CreateZedGraphControl();

            try
            {
                GraphPane pane = zg.GraphPane;

                int i   = 0;
                var ppd = new List <double>();
                foreach (var group in benchmarks.GroupBy(x => (x.SlotIdentifier, x.Processor, x.Threads)))
                {
                    PointPairList points;
                    string        label;
                    (points, label) = BuildSlotPoints(group.OrderBy(x => x.ProjectID), projectToXAxisOrdinal);

                    if (points.Count > 0)
                    {
                        // collection PPD values from all points
                        ppd.AddRange(points.Select(p => p.Y));

                        Color color = GetNextColor(i++, colors);
                        AddSlotCurve(pane, label, points, color);
                    }
                }

                if (ppd.Count > 0)
                {
                    var averagePPD    = ppd.Average();
                    var averagePoints = BuildAveragePoints(averagePPD, projectToXAxisOrdinal);
                    AddAverageCurve(pane, averagePoints);
                }

                ConfigureXAxis(pane.XAxis, projectToXAxisOrdinal);
                ConfigureYAxis(pane.YAxis, ppd.Max());

                FillGraphPane(pane);
            }
            finally
            {
                zg.AxisChange();
            }

            Result = zg;
        }