private void Increment(object state) { _heartbeat.IncrementCount(); if (RandomValueGenerator.GetRandomBool()) { Thread.Sleep(RandomValueGenerator.GetRandomInt(2)); } }
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"); }
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(); } } }
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"); } }
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"); }
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())); } }
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())); } }
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"); }
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"); } }
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"); }
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(); } } }
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"); } }