Beispiel #1
0
        public void Cpu()
        {
            Console.WriteLine("Nya");
            var configuration = Substitute.For <IMetricConfiguration>();

            configuration.Reporter.Returns(new TestOutputReporter());
            var scope = new RootMetricScope(configuration);

            scope.CpuLoad(1.Seconds());


            var compute = new Action(
                () =>
            {
                var sw = Stopwatch.StartNew();
                var x  = 1.0;
                while (sw.Elapsed < 10.Seconds())
                {
                    x = Math.Sin(Math.Sqrt(x + 10) + 3);
                }
                Console.WriteLine(x);
            });
            var threads = Enumerable.Range(0, 10).Select(_ => new Thread(() => compute())).ToArray();

            foreach (var t in threads)
            {
                t.Start();
            }
            foreach (var thread in threads)
            {
                thread.Join();
            }
        }
 public void SetUp()
 {
     eventReporter       = Substitute.For <IMetricEventReporter>();
     metricConfiguration = Substitute.For <IMetricConfiguration>();
     metricConfiguration.Reporter.Returns(eventReporter);
     scope = new RootMetricScope(metricConfiguration);
 }