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


C# System.Diagnostics类代码示例

本文整理汇总了C#中System.Diagnostics的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics类的具体用法?C# System.Diagnostics怎么用?C# System.Diagnostics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Test0

        public void Test0()
        {
            var intArrows =
                new []
                {
                    new IntArrow<int>(0, 10),
                    new IntArrow<int>(2, 20),
                    new IntArrow<int>(5, 10, 30),
                };

            const int DefaultValue = -1;

            var target = new BinaryDecisionTreeBuilder(DefaultValue, platformInfo);
            var node = target.Build(intArrows);
            PrintProgram(node);

            Assert.AreEqual(DefaultValue, Eval(node, -1));
            Assert.AreEqual(10, Eval(node, 0));
            Assert.AreEqual(DefaultValue, Eval(node, 1));
            Assert.AreEqual(20, Eval(node, 2));
            Assert.AreEqual(DefaultValue, Eval(node, 3));
            Assert.AreEqual(DefaultValue, Eval(node, 4));
            Assert.AreEqual(30, Eval(node, 5));
            Assert.AreEqual(30, Eval(node, 10));
            Assert.AreEqual(DefaultValue, Eval(node, 11));
        }
开发者ID:bkushnir,项目名称:IronTextLibrary,代码行数:26,代码来源:BinaryDecisionTreeBuilderTest.cs

示例2: TestSetup

		public void TestSetup()
		{
            UmbracoExamineSearcher.DisableInitializationCheck = true;
            BaseUmbracoIndexer.DisableInitializationCheck = true;
            //we'll copy over the pdf files first
		    var svc = new TestDataService();
		    var path = svc.MapPath("/App_Data/Converting_file_to_PDF.pdf");
		    var f = new FileInfo(path);
		    var dir = f.Directory;
            //ensure the folder is there
            System.IO.Directory.CreateDirectory(dir.FullName);
            var pdfs = new[] { TestFiles.Converting_file_to_PDF, TestFiles.PDFStandards, TestFiles.SurviorFlipCup, TestFiles.windows_vista };
            var names = new[] { "Converting_file_to_PDF.pdf", "PDFStandards.pdf", "SurviorFlipCup.pdf", "windows_vista.pdf" };
		    for (int index = 0; index < pdfs.Length; index++)
		    {
		        var p = pdfs[index];
		        using (var writer = File.Create(Path.Combine(dir.FullName, names[index])))
		        {
		            writer.Write(p, 0, p.Length);
		        }
		    }

		    _luceneDir = new RAMDirectory();
			_indexer = IndexInitializer.GetPdfIndexer(_luceneDir);
			_indexer.RebuildIndex();
			_searcher = IndexInitializer.GetUmbracoSearcher(_luceneDir);
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:27,代码来源:PdfIndexerTests.cs

示例3: Time

        public CodeTimerResult Time(int iteration, Action action)
        {
            // 1.
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            var gcCounts = new int[GC.MaxGeneration + 1];
            for (var i = 0; i <= GC.MaxGeneration; i++)
            {
                gcCounts[i] = GC.CollectionCount(i);
            }

            // 2.
            var watch = new Stopwatch();
            watch.Start();
            var cycleCount = GetCycleCount();
            for (var i = 0; i < iteration; i++) action();
            var cpuCycles = GetCycleCount() - cycleCount;
            watch.Stop();

            var gens = new [] { 0, 0, 0 };

            for (var i = 0; i < 3; i++)
            {
                if (i <= GC.MaxGeneration)
                {
                    gens[i] = GC.CollectionCount(i) - gcCounts[i];
                }
            }

            return new CodeTimerResult(watch.ElapsedMilliseconds, cpuCycles, gens[0], gens[1], gens[2]);
        }
开发者ID:nokia6102,项目名称:jasily.cologler,代码行数:30,代码来源:CodeTimer.cs

示例4: FiltersOutMissingProcesses

            public void FiltersOutMissingProcesses()
            {
                var processes = new[]
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var processIds = processes.Select(p => p.Id).ToList();
                    processIds.Add(1);

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                        x => Assert.Equal(processes[0].Id, x.Id),
                        x => Assert.Equal(processes[1].Id, x.Id)
                    );
                }
                finally
                {
                    foreach (var p in processes)
                        p.Kill();
                }
            }
开发者ID:stefanschneider,项目名称:IronFrame,代码行数:28,代码来源:ProcessHelperTest.cs

示例5: RunGremlinTest

        private void RunGremlinTest(string filePath)
        {
            var exifReader = new ExifReader();
            var sw = Stopwatch.StartNew();

            var app1 = File.ReadAllBytes(filePath);
            var segments = new[] { app1 };

            for (var i = 0; i < app1.Length; i++)
            {
                if (i % 1000 == 0)
                    _output.WriteLine($"{i}/{app1.Length} bytes");

                var original = app1[i];

                for (var b = byte.MinValue; b < byte.MaxValue; b++)
                {
                    app1[i] = b;

                    // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
                    exifReader.ReadJpegSegments(segments, JpegSegmentType.App1).ToList();
                }

                app1[i] = original;
            }

            _output.WriteLine($"Finished in {sw.Elapsed.TotalSeconds:#,##0.#} seconds");
        }
开发者ID:yjqGitHub,项目名称:metadata-extractor-dotnet,代码行数:28,代码来源:ExifReaderGremlinTest.cs

示例6: Can_have_meaningful_ids_on_documents

        public void Can_have_meaningful_ids_on_documents()
        {
            var city = new
            {
                Id = "usa/pa/philadelphia",
                Name = "Philadelphia",
                State = "Pennsylvania"
            };

            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(city);
                    session.SaveChanges();
                }

                // start another session for test purposes
                using (var session = store.OpenSession())
                {
                    var result = session.Load<dynamic>("usa/pa/philadelphia");
                    // we just loaded a document with a meaninful id
                    ((string)result.Name).Should().Be("Philadelphia");
                }
            }
        }
开发者ID:khalidabuhakmeh,项目名称:RavenDbTalk,代码行数:26,代码来源:1_Modeling.cs

示例7: FindView_ReturnsExpectedNotFoundResult_WithGetViewLocations

        public void FindView_ReturnsExpectedNotFoundResult_WithGetViewLocations()
        {
            // Arrange
            var expectedLocations = new[] { "location1", "location2" };
            var context = GetActionContext();
            var executor = GetViewExecutor();

            var viewName = "myview";
            var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
            viewEngine
                .Setup(e => e.GetView(/*executingFilePath*/ null, "myview", /*isMainPage*/ true))
                .Returns(ViewEngineResult.NotFound("myview", expectedLocations));
            viewEngine
                .Setup(e => e.FindView(context, "myview", /*isMainPage*/ true))
                .Returns(ViewEngineResult.NotFound("myview", Enumerable.Empty<string>()));

            var viewResult = new ViewResult
            {
                ViewName = viewName,
                ViewEngine = viewEngine.Object,
                ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider()),
                TempData = Mock.Of<ITempDataDictionary>(),
            };

            // Act
            var result = executor.FindView(context, viewResult);

            // Assert
            Assert.False(result.Success);
            Assert.Null(result.View);
            Assert.Equal(expectedLocations, result.SearchedLocations);
        }
开发者ID:phinq19,项目名称:git_example,代码行数:32,代码来源:ViewResultExecutorTest.cs

示例8: SimpleCalloutButtonClicked

        private void SimpleCalloutButtonClicked(object sender, System.EventArgs e)
        {
            var callout = SimpleIoc.Default.GetInstance<ICallout>();

            var buttonConfigs = new[] { new ButtonConfig("OK") };

            callout.Show("Simple Callout", "Message with some text.", buttonConfigs);
        }
开发者ID:thomasgalliker,项目名称:CrossPlatformLibrary.Callouts,代码行数:8,代码来源:MainPage.xaml.cs

示例9: SequenceIter

 private IAnalysisSet SequenceIter(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
     if (_iterator == null) {
         var types = new [] { new VariableDef() };
         types[0].AddTypes(unit, _indexTypes, false);
         _iterator = new IteratorInfo(types, IteratorInfo.GetIteratorTypeFromType(ClassInfo, unit), node);
     }
     return _iterator ?? AnalysisSet.Empty;
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:8,代码来源:SequenceBuiltinInstanceInfo.cs

示例10: IsSurroundedBy_detects_when_not_surrounded_on_three_diagonals

 public void IsSurroundedBy_detects_when_not_surrounded_on_three_diagonals()
 {
     var rectangles = new[]
     {
         new Rectangle(0, 0, 50, 50),
     };
     var result = new Point(50, 50).IsSurroundedBy(rectangles);
     Assert.Equal(false, result);
 }
开发者ID:nathanchere,项目名称:RelsTexturePackerNet,代码行数:9,代码来源:UtilsTests.cs

示例11: PlayDifferentMusicOnClick

 public void PlayDifferentMusicOnClick()
 {
     new FontText(Font.Default, "Click to Play", Rectangle.One);
     var music = ContentLoader.Load<Music>("DefaultMusic");
     var music2 = ContentLoader.Load<Music>("DefaultMusicBackwards");
     var musics = new[] { music, music2 };
     int index = 0;
     new Command(() => musics[(index++) % 2].Play(1f)).Add(new MouseButtonTrigger());
 }
开发者ID:remy22,项目名称:DeltaEngine,代码行数:9,代码来源:MusicTests.cs

示例12: Init

 internal static void Init()
 {
     var threadMacro = new[] { new ShaderMacro("NUMTHREADS", 8) };
     //MyRender11.RegisterSettingsChangedListener(new OnSettingsChangedDelegate(RecreateShadersForSettings));
     m_bloomShader = MyShaders.CreateCs("bloom_init.hlsl",threadMacro);
     m_downscaleShader = MyShaders.CreateCs("bloom_downscale.hlsl", threadMacro);
     m_blurH = MyShaders.CreateCs("bloom_blur_h.hlsl", threadMacro);
     m_blurV = MyShaders.CreateCs("bloom_blur_v.hlsl", threadMacro);
 }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyBloom.cs

示例13: Init

        internal static void Init()
        {
            var threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS) };
            m_initialShader = MyShaders.CreateCs("luminance_reduction_init.hlsl", threadMacros);
            m_sumShader = MyShaders.CreateCs("luminance_reduction.hlsl", threadMacros);

            threadMacros = new[] { new ShaderMacro("NUMTHREADS", NUM_THREADS), new ShaderMacro("_FINAL", null) };
            m_finalShader = MyShaders.CreateCs("luminance_reduction.hlsl", threadMacros);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyLuminanceAverage.cs

示例14: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            //AddHandler(MouseRightButtonDownEvent, new MouseButtonEventHandler(Window_MouseRightButtonDown), true);
            AddHandler(CustomButton.BubbledClickEvent, new RoutedEventHandler(AddBorder));

            MouseDown += (s, e) =>
            {
                TheText.Background = Brushes.Beige;
            };

            TheText.MouseDown += (s, e) =>
            {
                TheText.Background = Brushes.Azure;
                //This keeps the MouseDown handler on the window from raising
                e.Handled = true;
            };

            //MouseEnter is registered with a Direct routing strategy
            MouseEnter += (s, e) =>
            {
                TheText.Foreground = Brushes.Blue;
            };

            TheText.MouseEnter += (s, e) =>
            {
                TheText.Foreground = Brushes.Red;
            };

            TheOuterButton.Click += (s, e) =>
            {
                TheOuterButton.BorderBrush = new SolidColorBrush(new Color { R = 120, G = 145, B = 135 });
            };

            TheInnerButton.Click += (s, e) =>
            {
                TheOuterButton.BorderBrush = new SolidColorBrush(new Color { R = 45, G = 20, B = 35 });
                e.Handled = true;
            };

            //Setting handled here keeps the TextInput event on the TextBox from firing
            TheTextBox.PreviewTextInput += (s, e) =>
            {
                var numbers = new[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                if (e.Text.ToCharArray().All(x => !numbers.Contains(x)))
                    e.Handled = true;
            };

            TheCustomButton.DirectClick += (s, e) => Debug.WriteLine("Outer Direct Click");
            TheCustomButton.TunneledClick += (s, e) => Debug.WriteLine("Outer Tunneled Click");
            TheCustomButton.BubbledClick += (s, e) => Debug.WriteLine("Outer Bubbled Click");
            TheInnerCustomButton.DirectClick += (s, e) => Debug.WriteLine("Inner Direct Click");
            TheInnerCustomButton.TunneledClick += (s, e) => Debug.WriteLine("Inner Tunneled Click");
            TheInnerCustomButton.BubbledClick += (s, e) => Debug.WriteLine("Inner Bubbled Click");
        }
开发者ID:jchristian,项目名称:wpf_experimentation,代码行数:56,代码来源:MainWindow.xaml.cs

示例15: EuclidGcdManyArgsTimeTest

        public void EuclidGcdManyArgsTimeTest()
        {
            int[] array = new[] {9, 15, 21, 33, 99, 102};
            long period;

            int result = Gcd.EuclidGcd(out period, array);
            Debug.WriteLine(period);

            Assert.AreEqual(3, result);
        }
开发者ID:AlexanderChechet,项目名称:ASP.NET.AlexanderChechet.Day2,代码行数:10,代码来源:GcdTest.cs


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