当前位置: 首页>>代码示例>>C#>>正文


C# Stopwatch.Stop方法代码示例

本文整理汇总了C#中Stopwatch.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Stopwatch.Stop方法的具体用法?C# Stopwatch.Stop怎么用?C# Stopwatch.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stopwatch的用法示例。


在下文中一共展示了Stopwatch.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AsymmetricObjects

        private void AsymmetricObjects()
        {
            Console.WriteLine("Asymmetric");
            Console.WriteLine("----------");

            // bind
            var numberBinding = new Binding("Number") {Source = _guineaPig};
            var nameBinding = new Binding("FullName") {Source = _guineaPig};
            _subjectUnderTest.Number.SetBinding(System.Windows.Controls.TextBox.TextProperty, numberBinding);
            _subjectUnderTest.FullName.SetBinding(System.Windows.Controls.TextBox.TextProperty, nameBinding);

            var testDuration = new Stopwatch();
            testDuration.Start();
            RunAsymmetric();
            testDuration.Stop();
            Console.WriteLine(
                string.Format("Write to {0}: {1} msec.", _subjectUnderTest.GetType().Name, testDuration.ElapsedMilliseconds.ToString("#,###")));

            testDuration.Restart();
            RunReverseAsymmetric();
            testDuration.Stop();
            Console.WriteLine(
                string.Format("Write to {0}: {1} msec.", _guineaPig.GetType().Name, testDuration.ElapsedMilliseconds.ToString("#,###")));

            Console.WriteLine();
        }
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:26,代码来源:WpfTester.cs

示例2: run

		public static void run(Action testMethod, int rounds){
			Stopwatch stopwatch = new Stopwatch();
			stopwatch.Reset();
			stopwatch.Start();
			while (stopwatch.ElapsedMilliseconds < 1200)  // A Warmup of 1000-1500 mS 
				// stabilizes the CPU cache and pipeline.
			{
				testMethod(); // Warmup
				clearMemory ();
			}
			stopwatch.Stop();
			long totalmem;
			Console.WriteLine ("Round;Runtime ms;Memory KB");
			for (int repeat = 0; repeat < rounds; ++repeat)
			{
				stopwatch.Reset();
				stopwatch.Start();
				testMethod();
				stopwatch.Stop();
				totalmem = getUsedMemoryKB ();
				clearMemory ();
				Console.WriteLine((1+repeat)+";"+stopwatch.ElapsedMilliseconds + ";"
					+totalmem);
			}
		}
开发者ID:ResGear,项目名称:CryptobySharp,代码行数:25,代码来源:PerfMeter.cs

示例3: Main

    public static void Main()
    {
        Stopwatch watch = new Stopwatch();
        Random rand = new Random();
        watch.Start();
        for (int i = 0; i < iterations; i++)
            DayOfYear1(rand.Next(1, 13), rand.Next(1, 29));
        watch.Stop();
        Console.WriteLine("Local array: " + watch.Elapsed);
        watch.Reset();
        watch.Start();
        for (int i = 0; i < iterations; i++)
            DayOfYear2(rand.Next(1, 13), rand.Next(1, 29));
        watch.Stop();
        Console.WriteLine("Static array: " + watch.Elapsed);

        // trying to modify static int []
        daysCumulativeDays[0] = 18;
        foreach (int days in daysCumulativeDays)
        {
            Console.Write("{0}, ", days);
        }
        Console.WriteLine("");

        // MY_STR_CONST = "NOT CONST";
    }
开发者ID:joonhwan,项目名称:study,代码行数:26,代码来源:TestArrayInitialize.cs

示例4: should_be_within_performace_tolerance

        public void should_be_within_performace_tolerance()
        {
            var xml = File.ReadAllText("model.json").ParseJson();
            var json = JElement.Load(File.ReadAllBytes("model.json"));
            var stopwatch = new Stopwatch();

            var controlBenchmark = Enumerable.Range(1, 1000).Select(x =>
            {
                stopwatch.Restart();
                xml.EncodeJson();
                stopwatch.Stop();
                return stopwatch.ElapsedTicks;
            }).Skip(5).Average();

            var flexoBenchmark = Enumerable.Range(1, 1000).Select(x =>
            {
                stopwatch.Restart();
                json.Encode();
                stopwatch.Stop();
                return stopwatch.ElapsedTicks;
            }).Skip(5).Average();

            Console.Write("Control: {0}, Flexo: {1}", controlBenchmark, flexoBenchmark);

            flexoBenchmark.ShouldBeLessThan(controlBenchmark * 5);
        }
开发者ID:raidenyn,项目名称:Flexo,代码行数:26,代码来源:XmlJsonEncoderTests.cs

示例5: ECPerformanceTest

		public void ECPerformanceTest()
		{
			Stopwatch sw = new Stopwatch();
			int timesofTest = 1000;
			
			string[] timeElapsed = new string[2];
			string testCase = "sdg;alwsetuo1204985lkscvzlkjt;";
			sw.Start();
			
			for(int i = 0; i < timesofTest; i++)
			{
				this.Encode(testCase, 3);
			}
			
			sw.Stop();
			
			timeElapsed[0] = sw.ElapsedMilliseconds.ToString();
			
			sw.Reset();
			
			sw.Start();
			
			for(int i = 0; i < timesofTest; i++)
			{
				this.ZXEncode(testCase, 3);
			}
			sw.Stop();
			
			timeElapsed[1] = sw.ElapsedMilliseconds.ToString();
			
			
			Assert.Pass("EC performance {0} Tests~ QrCode.Net: {1} ZXing: {2}", timesofTest, timeElapsed[0], timeElapsed[1]);
			
		}
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:34,代码来源:EncodePTest.cs

示例6: btnInterpretate_Click

        private void btnInterpretate_Click(object sender, EventArgs e)
        {
            try
            {

                Stopwatch timer = new Stopwatch();
                RegularExpression r;

                timer.Reset();
                timer.Start();
                r = new RegularExpression(txtRegEx.Text);
                timer.Stop();
                ReportResult("Parsing '" + txtRegEx.Text + "'", "SUCCESS", r.IsCompiled, timer);

                timer.Reset();
                timer.Start();
                bool result = r.IsMatch(txtInput.Text);
                timer.Stop();
                ReportResult("Matching '" + txtInput.Text + "'", result.ToString(), r.IsCompiled, timer);

                ReportData("Original Expression:\t" + r.OriginalExpression + "\r\nInfix Expression:\t" + r.FormattedExpression + "\r\nPostfix string:\t" + r.PostfixExpression + "\r\n\r\nNon Deterministic Automata has\t\t" + r.NDStateCount + " states.\r\nDeterministic Automata has\t\t" + r.DStateCount + " states.\r\nOptimized Deterministic Automata has\t" + r.OptimizedDStateCount + " states.");

                automataViewer1.Initialize(r);
            }
            catch (RegularExpressionParser.RegularExpressionParserException exc)
            {
                ReportError("PARSER ERROR", exc.ToString());
            }
            catch (Exception exc)
            {
                ReportError("EXCEPTION", exc.ToString());
            }
        }
开发者ID:nzldvd90,项目名称:MidTermAP,代码行数:33,代码来源:Form1.cs

示例7: BackSequentialCompare

        public static void BackSequentialCompare(int countOfElementInArray)
        {
            int[] intArray = new int[countOfElementInArray];
            double[] doubleArray = new double[countOfElementInArray];
            string[] stringArray = new string[countOfElementInArray];

            for (int i = countOfElementInArray - 1; i >= 0; i--)
            {
                intArray[i] = i;
                doubleArray[i] = i;
                stringArray[i] = i.ToString();
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Restart();
            QuickSort<int>.Sort(intArray, Comparer<int>.Default);
            stopwatch.Stop();

            Console.WriteLine("Quick sort result for back sequential int is:{0}", stopwatch.ElapsedMilliseconds);

            stopwatch.Restart();
            QuickSort<double>.Sort(doubleArray, Comparer<double>.Default);
            stopwatch.Stop();

            Console.WriteLine("Quick sort result for back sequential double is:{0}", stopwatch.ElapsedMilliseconds);

            stopwatch.Restart();
            QuickSort<string>.Sort(stringArray, Comparer<string>.Default);
            stopwatch.Stop();

            Console.WriteLine("Quick sort result for back sequential string is:{0}", stopwatch.ElapsedMilliseconds);
        }
开发者ID:tddold,项目名称:Telerik-Academy-3,代码行数:33,代码来源:QuickSortComparer.cs

示例8: RunWithContext

        private static void RunWithContext(string topic, int iterations, Federation federation)
        {
            using (RequestContext.Create())
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                string content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
                stopwatch.Stop();

                Console.WriteLine("Rendered first times in {0} seconds", stopwatch.ElapsedMilliseconds / 1000.0F);

                stopwatch.Reset();
                stopwatch.Start();
                content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
                stopwatch.Stop();

                Console.WriteLine("Rendered second time in {0} seconds", stopwatch.ElapsedMilliseconds / 1000.0F);

                stopwatch.Reset();
                stopwatch.Start();
                content = federation.GetTopicFormattedContent(new QualifiedTopicRevision(topic), null);
                stopwatch.Stop();

                Console.WriteLine("Rendered third time in {0} seconds", stopwatch.ElapsedMilliseconds / 1000.0F);
            }
        }
开发者ID:nuxleus,项目名称:flexwikicore,代码行数:26,代码来源:Program.cs

示例9: TestCutLargeFile

        public void TestCutLargeFile()
        {
            var weiCheng = File.ReadAllText(@"Resources\围城.txt");
            var seg = new JiebaSegmenter();
            seg.Cut("热身");

            Console.WriteLine("Start to cut");
            var n = 20;
            var stopWatch = new Stopwatch();

            // Accurate mode
            stopWatch.Start();

            for (var i = 0; i < n; i++)
            {
                seg.Cut(weiCheng);
            }
            
            stopWatch.Stop();
            Console.WriteLine("Accurate mode: {0} ms", stopWatch.ElapsedMilliseconds / n);

            // Full mode
            stopWatch.Reset();
            stopWatch.Start();

            for (var i = 0; i < n; i++)
            {
                seg.Cut(weiCheng, true);
            }

            stopWatch.Stop();
            Console.WriteLine("Full mode: {0} ms", stopWatch.ElapsedMilliseconds / n);
        }
开发者ID:riiiqpl,项目名称:jieba.NET,代码行数:33,代码来源:TestSegmenterPerf.cs

示例10: Test_perf_of_query_without_index

        public void Test_perf_of_query_without_index()
        {
            OdbFactory.Delete("index1perf.ndb");
            using (var odb = OdbFactory.Open("index1perf.ndb"))
            {
                for (var i = 0; i < 5000; i++)
                {
                    var player = new Player("Player" + i, DateTime.Now, new Sport("Sport" + i));
                    odb.Store(player);
                }
            }

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            using (var odb = OdbFactory.OpenLast())
            {
                var query = odb.Query<Player>();
                query.Descend("Name").Constrain((object) "Player20").Equal();
                var count = query.Execute<Player>().Count;
                Assert.That(count, Is.EqualTo(1));
            }
            stopwatch.Stop();
            Console.WriteLine("Elapsed {0} ms", stopwatch.ElapsedMilliseconds);

            stopwatch.Reset();
            stopwatch.Start();
            using (var odb = OdbFactory.OpenLast())
            {
                var query = odb.Query<Player>();
                query.Descend("Name").Constrain((object) "Player1234").Equal();
                var count = query.Execute<Player>().Count;
                Assert.That(count, Is.EqualTo(1));
            }
            stopwatch.Stop();
            Console.WriteLine("Elapsed {0} ms", stopwatch.ElapsedMilliseconds);

            stopwatch.Reset();
            stopwatch.Start();
            using (var odb = OdbFactory.OpenLast())
            {
                var query = odb.Query<Player>();
                query.Descend("Name").Constrain((object) "Player4444").Equal();
                var count = query.Execute<Player>().Count;
                Assert.That(count, Is.EqualTo(1));
            }
            stopwatch.Stop();
            Console.WriteLine("Elapsed {0} ms", stopwatch.ElapsedMilliseconds);

            stopwatch.Reset();
            stopwatch.Start();
            using (var odb = OdbFactory.OpenLast())
            {
                var query = odb.Query<Player>();
                query.Descend("Name").Constrain((object) "Player3211").Equal();
                var count = query.Execute<Player>().Count;
                Assert.That(count, Is.EqualTo(1));
            }
            stopwatch.Stop();
            Console.WriteLine("Elapsed {0} ms", stopwatch.ElapsedMilliseconds);
        }
开发者ID:danfma,项目名称:NDB,代码行数:60,代码来源:Documentation_indexes.cs

示例11: FindAndSaveApps

        private int FindAndSaveApps(ICollection<int> partition) {
            ICollection<App> apps = appParser.RetrieveApps(partition);

            if (apps == null) {
                return 0;
            }

            Stopwatch watch = new Stopwatch();
            watch.Start();

            foreach (App app in apps) {
                repository.App.Save(app);

                indexer.AddApp(app);
            }

            watch.Stop();
            logger.Debug("Saved {0} apps using {1}ms", apps.Count, watch.ElapsedMilliseconds);

            watch.Reset();
            watch.Start();

            indexer.Flush();

            watch.Stop();
            logger.Debug("Indexed {0} apps using {1}ms", apps.Count, watch.ElapsedMilliseconds);

            return apps.Count;
        }
开发者ID:kahinke,项目名称:PingApp,代码行数:29,代码来源:InitializeTask.cs

示例12: WillWaitForItem

        public void WillWaitForItem() {
            using (var queue = GetQueue()) {
                queue.DeleteQueue();

                TimeSpan timeToWait = TimeSpan.FromSeconds(1);
                var sw = new Stopwatch();
                sw.Start();
                var workItem = queue.Dequeue(timeToWait);
                sw.Stop();
                Trace.WriteLine(sw.Elapsed);
                Assert.Null(workItem);
                Assert.True(sw.Elapsed > timeToWait.Subtract(TimeSpan.FromMilliseconds(10)));

                Task.Factory.StartNewDelayed(100, () => queue.Enqueue(new SimpleWorkItem {
                    Data = "Hello"
                }));

                sw.Reset();
                sw.Start();
                workItem = queue.Dequeue(timeToWait);
                workItem.Complete();
                sw.Stop();
                Trace.WriteLine(sw.Elapsed);
                Assert.NotNull(workItem);
            }
        }
开发者ID:WSmartJ18,项目名称:Exceptionless,代码行数:26,代码来源:InMemoryQueueTests.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        if (SVGFile != null) {
          Stopwatch w = new Stopwatch();

          w.Reset();
          w.Start();
          ISVGDevice device;
          if(useFastButBloatedRenderer)
        device = new SVGDeviceFast();
          else
        device = new SVGDeviceSmall();
          m_implement = new Implement(this.SVGFile, device);
          w.Stop();
          long c = w.ElapsedMilliseconds;

          w.Reset();
          w.Start();
          m_implement.StartProcess();
          w.Stop();
          long p = w.ElapsedMilliseconds;

          w.Reset();
          w.Start();
          renderer.material.mainTexture = m_implement.GetTexture();
          w.Stop();
          long r = w.ElapsedMilliseconds;
          UnityEngine.Debug.Log("Construction: " + Format(c) + ", Processing: " + Format(p) + ", Rendering: " + Format(r));

          Vector2 ts = renderer.material.mainTextureScale;
          ts.x *= -1;
          renderer.material.mainTextureScale = ts;
          renderer.material.mainTexture.filterMode = FilterMode.Trilinear;
        }
    }
开发者ID:nanuinteractive,项目名称:UnitySVG,代码行数:36,代码来源:Invoke.cs

示例14: BinaryStressTest

        public void BinaryStressTest()
        {
            var b = new Truck("MAN");

            var upper = Math.Pow(10, 3);

            var sw = new Stopwatch();

            sw.Start();

            b.LoadCargo(BinaryTestModels.ToList());

            sw.Stop();

            var secondElapsedToAdd = sw.ElapsedMilliseconds;

            Trace.WriteLine(string.Format("Put on the Channel {1} items. Time Elapsed: {0}", secondElapsedToAdd, upper));
            sw.Reset();
            sw.Start();

            b.DeliverTo("Dad");
            sw.Stop();

            var secondElapsedToBroadcast = sw.ElapsedMilliseconds ;

            Trace.WriteLine(string.Format("Broadcast on the Channel {1} items. Time Elapsed: {0}", secondElapsedToBroadcast, upper));

            var elem = b.UnStuffCargo<List<BinaryTestModel>>().First();

            Assert.AreEqual(elem.Count(), 1000, "Not every elements have been broadcasted");
            Assert.IsTrue(secondElapsedToAdd < 5000, "Add took more than 5 second. Review the logic, performance must be 10000 elems in less than 5 sec");
            Assert.IsTrue(secondElapsedToBroadcast < 3000, "Broadcast took more than 3 second. Review the logic, performance must be 10000 elems in less than 5 sec");
        }
开发者ID:nbasakuragi,项目名称:Grapple,代码行数:33,代码来源:PerformanceTest.cs

示例15: CopyConstructorSpeed

        public void CopyConstructorSpeed()
        {
            var random = new Random();

            var values = new double[5000000];
            for (var i = 0; i < 5000000; i++)
            {
                values[i] = random.Next();
            }

            var scalarSet = new ScalarSet(values);

            // copying values
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            values.Clone();
            stopwatch.Stop();

            var copyArrayTime = stopwatch.ElapsedMilliseconds;
            Trace.WriteLine("Copying array with 1M values took: " + copyArrayTime + " ms");

            stopwatch.Reset();
            stopwatch.Start();
            new ScalarSet(scalarSet);
            stopwatch.Stop();

            Trace.WriteLine("Copying scalar set with 1M values took: " + stopwatch.ElapsedMilliseconds + " ms");

            var fraction = stopwatch.ElapsedMilliseconds/copyArrayTime;

            Assert.IsTrue(fraction < 1.1);
        }
开发者ID:KangChaofan,项目名称:OOC,代码行数:32,代码来源:ScalarSetTest.cs


注:本文中的Stopwatch.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。