Beispiel #1
0
        private static void StartMainWindow(
            string loginDialogName,
            IApplicationConfigurator applicationConfigurator,
            IParametersProvider parametersProvider)
        {
            //Настрока удаления
            Configure.ConfigureDeletion();
            PerformanceHelper.AddTimePoint(logger, "Закончена настройка удаления");

            //Настройка сервисов
            if (parametersProvider.ContainsParameter("instant_sms_enabled_database") && parametersProvider.ContainsParameter("sms_service_address"))
            {
                if (parametersProvider.GetParameterValue("instant_sms_enabled_database") == loginDialogName)
                {
                    InstantSmsServiceSetting.Init(parametersProvider.GetParameterValue("sms_service_address"));
                }
            }

            if (parametersProvider.ContainsParameter("sms_payment_send_enabled_database") && parametersProvider.ContainsParameter("sms_payment_send_service_address"))
            {
                if (parametersProvider.GetParameterValue("sms_payment_send_enabled_database") == loginDialogName)
                {
                    SmsPaymentServiceSetting.Init(parametersProvider.GetParameterValue("sms_payment_send_service_address"));
                }
            }
            DriverApiParametersProvider.InitializeNotifications(parametersProvider, loginDialogName);

            CreateTempDir();

            //Запускаем программу
            MainWin                = new MainWindow(passwordValidator, applicationConfigurator);
            MainWin.Title         += $" (БД: {loginDialogName})";
            QSMain.ErrorDlgParrent = MainWin;
            MainWin.Show();
        }
Beispiel #2
0
        private void initDefaultWorld()
        {
            chunks = new Array3D <Chunk>(NumChunks);

            var totalTime = new TimeSpan(0);
            var i         = 0;

            chunks.ForEach((c, p) =>
            {
                i++;
                totalTime.Add(PerformanceHelper.Measure(() =>
                {
                    var grid = HermiteDataGrid.CopyGrid(new DensityFunctionHermiteGrid(v =>
                    {
                        v += (Vector3)p.ToVector3() * chunkSize;
                        return(20 - v.Y);
                    }, new Point3(chunkSize + 1, chunkSize + 1, chunkSize + 1)));

                    var chunk = new Chunk(p);
                    chunk.SetGrid(grid);
                    chunk.UpdateSurface(surfaceRenderer);
                    chunks[p] = chunk;
                }));
            });
            totalTime.Multiply(1f / i);
        }
Beispiel #3
0
        public async Task <ActionResult> AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            TryUpdateModel(order);

            if (ModelState.IsValid &&
                string.Equals(values["PromoCode"], PromoCode, StringComparison.OrdinalIgnoreCase))
            {
                order.Username  = User.Identity.Name;
                order.OrderDate = DateTime.Now;

                _storeContext.Orders.Add(order);

                await ShoppingCart.GetCart(_storeContext, this).CreateOrder(order);

                await _storeContext.SaveChangesAsync();

                PerformanceHelper.IncrementCounter(MusicStorePerformanceConstants.PaymentsCounterName);

                return(RedirectToAction("Complete", new { id = order.OrderId }));
            }

            return(View(order));
        }
        public void RemoveInstancesAndDispose_MultiInstanceCounters_Works(int numOfCounters)
        {
            // Arrange
            var helpers = new List <CounterHelper <MultiInstanceCategory> >();

            for (int i = 0; i < numOfCounters; i++)
            {
                var instanceName = GetInstanceName(i);
                helpers.Add(PerformanceHelper.CreateCounterHelper <MultiInstanceCategory>(instanceName));
            }

            //Act
            helpers.ForEach(helper => helper.RemoveInstancesAndDispose());

            // Assert
            for (int i = 0; i < numOfCounters; i++)
            {
                // The counters still exist
                Assert.IsTrue(PerformanceCounterCategory.CounterExists(AvgCounterName, CategoryName));
                Assert.IsTrue(PerformanceCounterCategory.CounterExists(NumCounterName, CategoryName));

                // The instances should NOT
                Assert.IsFalse(
                    PerformanceCounterCategory.InstanceExists(GetInstanceName(i), CategoryName),
                    string.Format("{0} should not exist anymore", GetInstanceName(i)));

                var category      = PerformanceCounterCategory.GetCategories().First(cat => cat.CategoryName == CategoryName);
                var instanceNames = category.GetInstanceNames().OrderBy(name => name).ToArray();
                Assert.AreEqual(0, instanceNames.Count(), "There should be no instances left");
            }
        }
Beispiel #5
0
 private static void ConfigureBindings(ContainerBuilder builder)
 {
     builder.Register(c => PerformanceHelper.CreateCounterHelper <Counters>())
     .SingleInstance()
     .As <CounterHelper <Counters> >();
     builder.RegisterType <Logger>().As <ILogger>();
 }
Beispiel #6
0
        public static void Start(int id, double coef)
        {
            var factory = new ConnectionFactory
            {
                HostName = "95.85.3.163",
                Password = "******",
                UserName = "******"
            };
            var properties = new BasicProperties {
                AppId = $"#{id}"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare("performance", false, false, false, null);

                    while (true)
                    {
                        var mould = PerformanceHelper.GetMould(coef);
                        var bytes = mould.ToBytes();
                        channel.BasicPublish("", "performance", properties, bytes);

                        Thread.Sleep(1000);
                    }
                }
        }
Beispiel #7
0
    protected void Page_Load2(object sender, EventArgs e)
    {
        list = YK.Service.AdminService.LogService.Search();

        PerformanceHelper ph = new PerformanceHelper();

        ph.Start("取数时间");
        Thread t1 = new Thread(new ParameterizedThreadStart(ExportExcel));
        Thread t2 = new Thread(new ParameterizedThreadStart(ExportExcel));
        Thread t3 = new Thread(new ParameterizedThreadStart(ExportExcel));
        Thread t4 = new Thread(new ParameterizedThreadStart(ExportExcel));
        Thread t5 = new Thread(new ParameterizedThreadStart(ExportExcel));
        Thread t6 = new Thread(new ParameterizedThreadStart(ExportExcel));

        t1.Start(1);
        t2.Start(2);
        t3.Start(3);
        t4.Start(4);
        t5.Start(5);
        t6.Start(6);
        ph.Stop();

        Thread.Sleep(60000);
        ExportZip();
    }
Beispiel #8
0
        public async Task DoAsync(int awaitMills)
        {
            TimeSpan elapsedTime = TimeSpan.Zero;
            await PerformanceHelper.DoAsync(async() => await Task.Delay(awaitMills), ts => elapsedTime = ts);

            Assert.True(elapsedTime.TotalMilliseconds >= awaitMills);
        }
Beispiel #9
0
    public void ExportExcel()
    {
        PerformanceHelper ph = new PerformanceHelper();

        ph.Start("取数时间");
        var list = YK.Service.AdminService.LogService.Search();

        ph.Stop();
        ph.Start("导出时间");
        var teamplatePath = Server.MapPath("~/老客户列表.xlsx");
        var savePath1     = Server.MapPath("~/products1.xlsx");
        var savePath2     = Server.MapPath("~/products2.xlsx");
        var savePath3     = Server.MapPath("~/products3.xlsx");
        var savePath4     = Server.MapPath("~/products4.xlsx");
        var savePath5     = Server.MapPath("~/products5.xlsx");
        var savePath6     = Server.MapPath("~/products6.xlsx");

        YK.Common.Excel.ExcelHelper helper = new YK.Common.Excel.ExcelHelper();
        helper.DataRowStart    = 2;
        helper.DataColumnStart = 0;

        helper.Export(list.Skip(20000 * 0).Take(20000), teamplatePath, savePath1);
        helper.Export(list.Skip(20000 * 1).Take(20000), teamplatePath, savePath2);
        helper.Export(list.Skip(20000 * 2).Take(20000), teamplatePath, savePath3);
        helper.Export(list.Skip(20000 * 3).Take(20000), teamplatePath, savePath4);
        helper.Export(list.Skip(20000 * 4).Take(20000), teamplatePath, savePath5);
        helper.Export(list.Skip(20000 * 5).Take(20000), teamplatePath, savePath6);

        ph.Stop();
    }
Beispiel #10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            var counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("");

            counterHelper.RawValue(Counters.GoToIndex, 0);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
        static SiteNodeHelper()
        {
            _performanceHelper = PerformanceHelper.CreateCounterHelper <Counters>("Test");

            _performanceHelper.RawValue(Counters.SuccessfullHttpRequests, 0);
            _performanceHelper.RawValue(Counters.FailedHttpRequests, 0);
        }
Beispiel #12
0
        private static void TestSlicing()
        {
            var _slicer = new MSTLSlicer();

            _slicer.Load(@"C:\MSOLV\STLs\Ice Cream Type 2.stl");
            //_slicer.Load(@"C:\MSOLV\STLs\tray.stl");
            //_slicer.Load(@"C:\MSOLV\STLs\flange.stl");
            //_slicer.Load(@"C:\MSOLV\STLs\TestBinaryKIT.stl");

            List <ContourStructure>[]  control = new List <ContourStructure>[] { };
            List <MContourStructure>[] slices  = new List <MContourStructure>[] { };

            Console.WriteLine(
                PerformanceHelper.Compare(
                    () =>
            {
                control = _slicer.Slice();
            },
                    () =>
            {
                slices = _slicer.SliceParallel();
            },
                    compareRepeat: 5,
                    timingRepeat: 5,
                    tagA: "Control",
                    tagB: "Slices"
                    )
                );

            //PrintSlicesCount("Control", control);
            //PrintSlicesCount("Slices", slices);
        }
Beispiel #13
0
        public void UpdateDirty()
        {
            if (!dirty)
            {
                return;
            }
            dirty = false;

            ((HermiteDataGrid)grid).Save(TWDir.Test.CreateSubdirectory("DualContouring").CreateFile("InteractiveGrid.txt"));


            lastSurfaceExtractionTime = PerformanceHelper.Measure(() =>
            {
                surfaceMesh = dcMeshBuilder.buildRawMesh(grid);
            });

            if (meshElement != null)
            {
                meshElement.Delete();
            }
            meshElement             = surfaceRenderer.CreateSurface(grid, Matrix.Identity);
            meshElement.WorldMatrix = Matrix.Scaling(new Vector3(CellSize));

            this.lines.ClearAllLines();
            addHermiteVertices(grid, CellSize, this.lines);
            addQEFPoints(surfaceMesh, CellSize, this.lines);
            addHermiteNormals(grid, CellSize, this.lines);

            lines.AddBox(new BoundingBox(new Vector3(), grid.Dimensions.ToVector3() * cellSize), Color.Black);
        }
        protected void Application_Start()
        {
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(HomeController).Assembly);
            builder.Register(f => LogManager.GetLogger("ForControllers")).
            As <ILogger>();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build()));

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            logger.Info("Application Started");

            using (var counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("Enter Home counter instance"))
            {
                counterHelper.RawValue(Counters.GoToHome, 0);
            }
            using (var counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("Successful Log in counter instance"))
            {
                counterHelper.RawValue(Counters.SuccessLogIn, 0);
            }
            using (var counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("Successful Log off counter instance"))
            {
                counterHelper.RawValue(Counters.successLogOff, 0);
            }
        }
        public ActionResult LogOff()
        {
            AuthenticationManager.SignOut();

            PerformanceHelper.IncrementCounter(MusicStorePerformanceConstants.LogoffCounterName);

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #16
0
        public void GetPerformanceType_ReturnsCorrectly(string dateStr, int referenceHour, string expected)
        {
            var date = TestHelper.ConvertTestArgumentToDateTime(dateStr);

            var result = PerformanceHelper.GetPerformanceType(date, referenceHour);

            Assert.AreEqual(expected, result);
        }
        private static void IncrementStartAppCounter()
        {
            var counterHelper = PerformanceHelper.CreateCounterHelper <PerformanceCounters>("Test counters");

            counterHelper.RawValue(PerformanceCounters.StartApplication, 0);
            counterHelper.RawValue(PerformanceCounters.SuccessLogIn, 0);
            counterHelper.RawValue(PerformanceCounters.SuccessLogOf, 0);
            counterHelper.Increment(PerformanceCounters.StartApplication);
        }
Beispiel #18
0
        public void PerformanceOfNFibonacci()
        {
            int numFibs = 12;

            PerformanceHelper.PerformanceTestAction(() => FibonacciIterative().Take(numFibs).ToList(), "FibonacciIterative");
            PerformanceHelper.PerformanceTestAction(() => FibonacciRecursive().Take(numFibs).ToList(), "FibonacciRecursive");
            PerformanceHelper.PerformanceTestAction(() => Enumerable.Range(0, numFibs).Select(FibonacciN).ToList(), "FibonacciN");
            PerformanceHelper.PerformanceTestAction(() => Enumerable.Range(0, numFibs).Select(FibonacciNMemoization).ToList(), "FibonacciNMemoization");
        }
Beispiel #19
0
 public AccountController(UserManager <ApplicationUser> userManager)
 {
     _userManager  = userManager;
     counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("MvcMusicStore");
     if (ConfigurationManager.AppSettings["Logging"].AsBool())
     {
         logger = new Logger();
     }
 }
 private void MainForm_Load(object sender, EventArgs e)
 {
     counterHelper = PerformanceHelper.CreateCounterHelper <SingleInstance_PerformanceCounters>();
     if (counterHelper == null)
     {
         MessageBox.Show("Counter not installed. Attempting to install.");
         PerformanceHelper.Install(typeof(SingleInstance_PerformanceCounters));
     }
 }
Beispiel #21
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            var counterHelper = PerformanceHelper.CreateCounterHelper <StoreCounters>("Store project");

            counterHelper.RawValue(StoreCounters.GoToHome, 0);
        }
Beispiel #22
0
        public ActionResult LogOff()
        {
            AuthenticationManager.SignOut();

            var counterHelper = PerformanceHelper.CreateCounterHelper <PerfomanceCounters>("Mvc project");

            counterHelper.Increment(PerfomanceCounters.LogOff);

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #23
0
        public static void SetKeywordValue(string name, string value, PerformanceMode performanceMode)
        {
            var performanceKey = uniqueKey + name;

            Func <string, string, bool> fnc = SetKeywordValueToSettings;

            var args = new object[] { name, value };

            PerformanceHelper.Update <string>(performanceMode, performanceKey, value, fnc, args);
        }
Beispiel #24
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         Debug.Log("aaaaaaaaaaaaaaaaaaa");
         List <int> temp = new List <int>();
         temp.AddRange(data);
         PerformanceHelper.WatchPerformance("归并排序算法效率  ", () => { MergeSortHelper.Sort <int>(data, 0, data.Count - 1, CompareRather, temp); });
     }
 }
Beispiel #25
0
        /// <summary>
        /// Internal Constructor for named instances (multi-instance counters)
        /// </summary>
        /// <param name="instanceName">name for this instance</param>
        /// <param name="categoryInfo">information about this category</param>
        /// <param name="enumCounterAttributes">enumerator attributes</param>
        /// <exception cref="System.NotSupportedException" />
        internal CounterHelperImpl(string instanceName, PerformanceCounterCategoryAttribute categoryInfo, Dictionary <T, PerformanceCounterAttribute> enumCounterAttributes)
            : this(enumCounterAttributes.Count, instanceName)
        {
            if ((categoryInfo.InstanceType == PerformanceCounterCategoryType.MultiInstance) &&
                (string.IsNullOrEmpty(instanceName)))
            {
                throw new NotSupportedException(Properties.Resources.CounterHelper_MultiInstanceNoInstanceNameErrorMessage);
            }

            PerformanceCounter performanceCounter, performanceCounterBase = null;

            Dictionary <T, PerformanceCounterAttribute> .Enumerator enumerator = enumCounterAttributes.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (categoryInfo.InstanceType == PerformanceCounterCategoryType.MultiInstance)
                {
                    performanceCounter = new PerformanceCounter(categoryInfo.Name,
                                                                enumerator.Current.Value.Name,
                                                                this._instanceName,
                                                                false);
                }
                else
                {
                    performanceCounter = new PerformanceCounter(categoryInfo.Name,
                                                                enumerator.Current.Value.Name,
                                                                false);
                }
                PerformanceCounterType?baseType = PerformanceHelper.GetBaseType(performanceCounter.CounterType);

                if (baseType != null)
                {
                    if (categoryInfo.InstanceType == PerformanceCounterCategoryType.MultiInstance)
                    {
                        performanceCounterBase = new PerformanceCounter(categoryInfo.Name,
                                                                        PerformanceHelper.GetCounterNameForBaseType(enumerator.Current.Value.Name),
                                                                        instanceName,
                                                                        false);
                    }
                    else
                    {
                        performanceCounterBase = new PerformanceCounter(categoryInfo.Name,
                                                                        PerformanceHelper.GetCounterNameForBaseType(enumerator.Current.Value.Name),
                                                                        false);
                    }
                    performanceCounterBase.RawValue = PerformanceHelper.getInitialValue(performanceCounter.CounterType);
                }
                else
                {
                    performanceCounterBase = null;
                }

                PerformanceCounterContainer performanceCounterContainer = new PerformanceCounterContainer(performanceCounter, performanceCounterBase, enumerator.Current.Value.IsBaseAutoIncreased);
                this._counters.Add(enumerator.Current.Key, performanceCounterContainer);
            }
        }
Beispiel #26
0
            public void TestQ1P5RunLengthEncodingPerformance()
            {
                var head = new Node <int>(1);

                head.Append(2);
                head.Append(3);
                head.Append(4);
                head.Append(5);

                PerformanceHelper.PerformanceTestPublicStaticMethods <Q2P2FindKthToLastElementOfLinkedList, int>(head, 4);
            }
        private void CreateAndCleanup(int countersToCreate, Action <CounterHelper <MultiInstanceCategory> > cleanupMethod)
        {
            for (int i = 0; i < countersToCreate; i++)
            {
                // Arrange
                var instanceName = GetInstanceName(i);
                var helper       = PerformanceHelper.CreateCounterHelper <MultiInstanceCategory>(instanceName);

                //Act
                cleanupMethod(helper);
            }
        }
Beispiel #28
0
        public IActionResult Index()
        {
            var counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("");

            counterHelper.Increment(Counters.GoToIndex);

            _logger.LogError("Request header are empty");

            _logger.LogInformation("Method index finished");

            return(View());
        }
Beispiel #29
0
        public static List <Language> GetLanguages(PerformanceMode performanceMode)
        {
            var keyValue = new List <Language>();

            Func <List <Language> > fnc = GetLanguagesFromSettings;

            var args = (object[])null;

            PerformanceHelper.GetPerformance(performanceMode, languagesUniqueKey, out keyValue, fnc, args);

            return(keyValue);
        }
Beispiel #30
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            using (var counterHelper = PerformanceHelper.CreateCounterHelper <Counters>("MvcMusicStore"))
            {
                counterHelper.RawValue(Counters.Login, 0);
            }
        }