Example #1
0
 private void Increment(object state)
 {
     _heartbeat.IncrementCount();
     if (RandomValueGenerator.GetRandomBool())
     {
         Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
     }
 }
Example #2
0
        public void RunCount_NoHandler()
        {
            long countInterval = 5000;
            long countTo       = RandomValueGenerator.GetRandomInt(1000, 50000);
            var  heartbeat     = new hb.Heartbeat(this, countInterval, 0);

            heartbeat.Start("RunCount_NoHandler, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
            for (int i = 0; i < countTo; i++)
            {
                heartbeat.IncrementCount();
            }
            heartbeat.SetComplete("RunCount_NoHandler finished");
        }
Example #3
0
        public void RunCount_NoCompletion()
        {
            long countInterval = 5000;
            long countTo       = RandomValueGenerator.GetRandomInt(1000, 50000);

            using (var heartbeat = new hb.Heartbeat(this, countInterval, 0))
            {
                heartbeat.Start("RunCount_NoCompletion, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
                for (int i = 0; i < countTo; i++)
                {
                    heartbeat.IncrementCount();
                }
            }
        }
Example #4
0
        public void RunCount()
        {
            long countInterval = 5000;
            long countTo       = RandomValueGenerator.GetRandomInt(1000, 50000);

            using (var heartbeat = new hb.Heartbeat(this, countInterval, 0))
            {
                heartbeat.OnPulse += new Sixeyed.Heartbeat.Heartbeat.OnPulseEventHanlder(RunCount_OnPulse);
                heartbeat.Start("RunCount, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
                for (int i = 0; i < countTo; i++)
                {
                    heartbeat.IncrementCount();
                }
                heartbeat.SetComplete("RunCount finished");
            }
        }
Example #5
0
        public void RunCountAndTimer_NoHandler()
        {
            long   countInterval = 1000;
            long   countTo       = RandomValueGenerator.GetRandomInt(1000, 10000);
            double timerInterval = 800; //0.8 seconds
            var    runTime       = RandomValueGenerator.GetRandomInt(3 * 1000, 10 * 1000);
            var    heartbeat     = new hb.Heartbeat(this, countInterval, timerInterval);

            heartbeat.Start("RunCountAndTimer_NoHandler, countInterval: {0}, countTo: {1}, timerInterval: {2}, runTime: {3}"
                            .FormatWith(countInterval, countTo, timerInterval, runTime));
            for (int i = 0; i < countTo; i++)
            {
                heartbeat.IncrementCount();
                if (RandomValueGenerator.GetRandomBool())
                {
                    Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
                }
            }
            heartbeat.SetComplete("RunCountAndTimer_NoHandler finished");
        }
Example #6
0
        public void RunCount_Failure()
        {
            long countInterval = 5000;
            long countTo       = RandomValueGenerator.GetRandomInt(1000, 50000);
            var  heartbeat     = new hb.Heartbeat(this, countInterval, 0);

            heartbeat.Start("RunCount_NoHandler, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
            try
            {
                for (int i = 0; i < countTo; i++)
                {
                    heartbeat.IncrementCount();
                }
                var zero = 0;
                var dbz  = 1 / zero;
                heartbeat.SetComplete("RunCount_NoHandler finished");
            }
            catch (Exception ex)
            {
                heartbeat.SetFailed("RunCount_NoHandler failed, message: {0}".FormatWith(ex.FullMessage()));
            }
        }
Example #7
0
     public void RunCount_Failure()
     {
         long countInterval = 5000;
         long countTo = RandomValueGenerator.GetRandomInt(1000, 50000);
 var heartbeat = new hb.Heartbeat(this, countInterval, 0);
 heartbeat.Start("RunCount_NoHandler, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
 try
 {
     for (int i = 0; i < countTo; i++)
     {
         heartbeat.IncrementCount();
     }
     var zero = 0;
     var dbz = 1 / zero;
     heartbeat.SetComplete("RunCount_NoHandler finished");
 }
 catch (Exception ex)
 {
     heartbeat.SetFailed("RunCount_NoHandler failed, message: {0}".FormatWith(ex.FullMessage()));
 }
     }
Example #8
0
     public void RunCount_NoHandler()
     {
         long countInterval = 5000;
         long countTo = RandomValueGenerator.GetRandomInt(1000, 50000);
         var heartbeat = new hb.Heartbeat(this, countInterval, 0);
 heartbeat.Start("RunCount_NoHandler, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
         for (int i = 0; i < countTo; i++)
         {
             heartbeat.IncrementCount();
         }
         heartbeat.SetComplete("RunCount_NoHandler finished");
     }
Example #9
0
 private void DoWork(Heartbeat heartbeat, long taskIndex, long finalTaskIndex)
 {
     heartbeat.IncrementCount();
     //fake work:
     if (RandomValueGenerator.GetRandomBool())
     {
         Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
     }            
     if (taskIndex == finalTaskIndex)
     {
         heartbeat.SetComplete("RunCountAndTimer_NoHandler_WithTasks finished");
     }
 }
Example #10
0
 public void RunCountAndTimer_NoHandler()
 {
     long countInterval = 1000;
     long countTo = RandomValueGenerator.GetRandomInt(1000, 10000);
     double timerInterval = 800; //0.8 seconds
     var runTime = RandomValueGenerator.GetRandomInt(3 * 1000, 10 * 1000);
     var heartbeat = new hb.Heartbeat(this, countInterval, timerInterval);
     heartbeat.Start("RunCountAndTimer_NoHandler, countInterval: {0}, countTo: {1}, timerInterval: {2}, runTime: {3}"
                         .FormatWith(countInterval, countTo, timerInterval, runTime));
     for (int i = 0; i < countTo; i++)
     {
         heartbeat.IncrementCount();
         if (RandomValueGenerator.GetRandomBool())
         {
             Thread.Sleep(RandomValueGenerator.GetRandomInt(2));
         }
     }
     heartbeat.SetComplete("RunCountAndTimer_NoHandler finished");
 }
Example #11
0
 public void RunCount_NoCompletion()
 {
     long countInterval = 5000;
     long countTo = RandomValueGenerator.GetRandomInt(1000, 50000);
     using (var heartbeat = new hb.Heartbeat(this, countInterval, 0))
     {
         heartbeat.Start("RunCount_NoCompletion, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
         for (int i = 0; i < countTo; i++)
         {
             heartbeat.IncrementCount();
         }
     }
 }
Example #12
0
 public void RunCount()
 {
     long countInterval = 5000;
     long countTo = RandomValueGenerator.GetRandomInt(1000, 50000);
     using (var heartbeat = new hb.Heartbeat(this, countInterval, 0))
     {
         heartbeat.OnPulse += new Sixeyed.Heartbeat.Heartbeat.OnPulseEventHanlder(RunCount_OnPulse);
         heartbeat.Start("RunCount, countInterval: {0}, countTo: {1}".FormatWith(countInterval, countTo));
         for (int i = 0; i < countTo; i++)
         {
             heartbeat.IncrementCount();
         }
         heartbeat.SetComplete("RunCount finished");
     }
 }