예제 #1
0
        public void BioData()
        {
            var start    = DateTime.Now;
            var resolver = new SimpleInjectorOwinResolutionContext(new ExecutionContextScopeLifestyle(), RegisterTypes);

            Console.WriteLine($"Registered dependencies in: {DateTime.Now - start}\n\n\n");

            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var accManager = scope.Resolve <IAccountManager>();
                Console.WriteLine($"IAccountManager resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bio = accManager.GetBioData();
                Console.WriteLine($"IAccountManager.GetBioData({bio.Succeeded}) executed in: {DateTime.Now - start}\n\n");
            }

            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var accManager = scope.Resolve <IAccountManager>();
                Console.WriteLine($"IAccountManager resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bio = accManager.GetBioData();
                Console.WriteLine($"IAccountManager.GetBioData({bio.Succeeded}) executed in: {DateTime.Now - start}\n\n");
            }

            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var accManager = scope.Resolve <IAccountManager>();
                Console.WriteLine($"IAccountManager resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bio = accManager.GetBioData();
                Console.WriteLine($"IAccountManager.GetBioData({bio.Succeeded}) executed in: {DateTime.Now - start}\n\n");
            }

            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var accManager = scope.Resolve <IAccountManager>();
                Console.WriteLine($"IAccountManager resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bio = accManager.GetBioData();
                Console.WriteLine($"IAccountManager.GetBioData({bio.Succeeded}) executed in: {DateTime.Now - start}\n\n");
            }

            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var accManager = scope.Resolve <IAccountManager>();
                Console.WriteLine($"IAccountManager resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bio = accManager.GetBioData();
                Console.WriteLine($"IAccountManager.GetBioData({bio.Succeeded}) executed in: {DateTime.Now - start}\n\n");
            }
        }
        public void DISpeedTest()
        {
            var start    = DateTime.Now;
            var resolver = new SimpleInjectorOwinResolutionContext(new ExecutionContextScopeLifestyle(), RegisterTypes);

            Console.WriteLine($"Registered dependencies in: {DateTime.Now - start}\n\n\n");

            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var bcManager = scope.Resolve <IBlockChainService>();
                Console.WriteLine($"BlockChainService resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bcController = scope.Resolve <BlockChainController>();
                Console.WriteLine($"BlockChainController resolved in: {DateTime.Now - start}");

                var data = Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"PageSize\":20, \"PageIndex\":0}"));
                start = DateTime.Now;
                var opr = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"1st run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"2nd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);
                Console.WriteLine($"3rd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");
            }


            Console.WriteLine("\n\n\n");
            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var bcManager = scope.Resolve <IBlockChainService>();
                Console.WriteLine($"BlockChainService resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bcController = scope.Resolve <BlockChainController>();
                Console.WriteLine($"BlockChainController resolved in: {DateTime.Now - start}");

                var data = Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"PageSize\":20, \"PageIndex\":0}"));
                start = DateTime.Now;
                var opr = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"1st run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"2nd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);
                Console.WriteLine($"3rd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");
            }


            Console.WriteLine("\n\n\n");
            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var bcManager = scope.Resolve <IBlockChainService>();
                Console.WriteLine($"BlockChainService resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bcController = scope.Resolve <BlockChainController>();
                Console.WriteLine($"BlockChainController resolved in: {DateTime.Now - start}");

                var data = Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"PageSize\":20, \"PageIndex\":0}"));
                start = DateTime.Now;
                var opr = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"1st run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"2nd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);
                Console.WriteLine($"3rd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");
            }


            Console.WriteLine("\n\n\n");
            using (var scope = resolver.NewResolutionScope())
            {
                start = DateTime.Now;
                var bcManager = scope.Resolve <IBlockChainService>();
                Console.WriteLine($"BlockChainService resolved in: {DateTime.Now - start}");

                start = DateTime.Now;
                var bcController = scope.Resolve <BlockChainController>();
                Console.WriteLine($"BlockChainController resolved in: {DateTime.Now - start}");

                var data = Convert.ToBase64String(Encoding.UTF8.GetBytes("{\"PageSize\":20, \"PageIndex\":0}"));
                start = DateTime.Now;
                var opr = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"1st run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);//.GetOutgoingUserTransactions(20, 0);
                Console.WriteLine($"2nd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");


                start = DateTime.Now;
                opr   = bcController.GetOutgoingUserTransactions(data);
                Console.WriteLine($"3rd run bcController.GetOutgoingUserTransactions executed in: {DateTime.Now - start}");
            }
        }