private void trax() { __threadCount = tbTraxThreads.Text.AsInt(1); __writesSec = tbTraxWrites.Text.AsInt(0); __delSec = tbTraxDeletes.Text.AsInt(0); __payloadVariance = tbTraxVariance.Text.AsInt(0); __payloadType = rbtPerson.Checked ? ptype.Person : rbtPerson2.Checked ? ptype.Person2 : rbtString.Checked ? ptype.String : ptype.ByteArray; var added = 0; while (chkTraxer.Checked && m_Traxers.Count < __threadCount) { var context = new tcontext(); var thread = new Thread( (ctx) => { try { var pps = new PilePointer[4000000]; for (var i = 0; i < pps.Length; i++) { pps[i] = PilePointer.Invalid; } var ppi = 0; var di = 0; while (m_Pile.Running && !((tcontext)ctx).STOP) { var tc = __threadCount; if (tc == 0) { return; } var wc = __writesSec / tc; var dc = __delSec / tc; var w = 0; var d = 0; while (w < wc || d < dc) { if (w < wc) { object payload; if (__payloadType == ptype.Person) { var p = Person.MakeFake(); if (__payloadVariance > 0) { p.BinData = new byte[IntMath.ChangeByRndPct(__payloadVariance, -0.25f)]; } payload = p; } else if (__payloadType == ptype.Person2) { var p = Person2.MakeFake2(); if (__payloadVariance > 0) { p.BinData = new byte[IntMath.ChangeByRndPct(__payloadVariance, -0.25f)]; } payload = p; } else if (__payloadType == ptype.String) { payload = new string(' ', __payloadVariance); } else { payload = new byte[__payloadVariance]; } var pp = m_Pile.Put(payload); pps[ppi] = pp; ppi++; if (ppi == pps.Length) { ppi = 0; } w++; } if (d < dc) { if (di == pps.Length) { di = 0; } var pp = pps[di]; if (pp.Address >= 0) { m_Pile.Delete(pp); pps[di] = PilePointer.Invalid; } d++; di++; } } } } catch (Exception error)//abort etc.. { m_Errors.Enqueue(error.ToMessageWithType()); } }); m_Traxers.Add(context); thread.Start(context); added++; } if (added > 0) { log("{0} added {1} threads".Args(DateTime.Now, added)); } var removed = 0; while ((!chkTraxer.Checked && m_Traxers.Count > 0) || m_Traxers.Count > __threadCount) { m_Traxers[0].STOP = true; m_Traxers.RemoveAt(0); removed++; } if (removed > 0) { log("{0} removed {1} threads".Args(DateTime.Now, removed)); } }
private void trax() { __threadCount = tbTraxThreads.Text.AsInt(1); __writesSec = tbTraxWrites.Text.AsInt(0); __delSec = tbTraxDeletes.Text.AsInt(0); __payloadVariance = tbTraxVariance.Text.AsInt(0); var added = 0; while (chkTraxer.Checked && m_Traxers.Count < __threadCount) { var context = new tcontext(); var thread = new Thread( (ctx) => { try { var pps = new PilePointer[2000000]; for(var i=0; i<pps.Length; i++) pps[i] = PilePointer.Invalid; var ppi = 0; var di=0; while(m_Pile.Running && !((tcontext)ctx).STOP) { var tc = __threadCount; if (tc==0) return; var wc = __writesSec / tc; var dc = __delSec / tc; var w=0; var d=0; while(w<wc || d<dc) { if (w<wc) { var obj = Person.MakeFake(); if (__payloadVariance>0) obj.BinData = new byte[__payloadVariance]; var pp = m_Pile.Put( obj ); pps[ppi] = pp; ppi++; if (ppi==pps.Length) ppi = 0; w++; } if (d<dc) { if (di==pps.Length) di = 0; var pp = pps[di]; if (pp.Address>=0) { m_Pile.Delete( pp ); pps[di] = PilePointer.Invalid; } d++; di++; } } Thread.Sleep(90+ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 20)); } } catch(Exception error)//abort etc.. { m_Errors.Enqueue(error.ToMessageWithType()); } }); m_Traxers.Add(context); thread.Start(context); added++; } if (added>0) log("{0} added {1} threads".Args(DateTime.Now, added)); var removed = 0; while ((!chkTraxer.Checked&&m_Traxers.Count>0) || m_Traxers.Count > __threadCount) { m_Traxers[0].STOP = true; m_Traxers.RemoveAt(0); removed++; } if (removed>0) log("{0} removed {1} threads".Args(DateTime.Now, removed)); }
private void trax() { __threadCount = tbTraxThreads.Text.AsInt(1); __writesSec = tbTraxWrites.Text.AsInt(0); __delSec = tbTraxDeletes.Text.AsInt(0); __payloadVariance = tbTraxVariance.Text.AsInt(0); var added = 0; while (chkTraxer.Checked && m_Traxers.Count < __threadCount) { var context = new tcontext(); var thread = new Thread( (ctx) => { try { var pps = new PilePointer[2000000]; for (var i = 0; i < pps.Length; i++) { pps[i] = PilePointer.Invalid; } var ppi = 0; var di = 0; while (m_Pile.Running && !((tcontext)ctx).STOP) { var tc = __threadCount; if (tc == 0) { return; } var wc = __writesSec / tc; var dc = __delSec / tc; var w = 0; var d = 0; while (w < wc || d < dc) { if (w < wc) { var obj = Person.MakeFake(); if (__payloadVariance > 0) { obj.BinData = new byte[__payloadVariance]; } var pp = m_Pile.Put(obj); pps[ppi] = pp; ppi++; if (ppi == pps.Length) { ppi = 0; } w++; } if (d < dc) { if (di == pps.Length) { di = 0; } var pp = pps[di]; if (pp.Address >= 0) { m_Pile.Delete(pp); pps[di] = PilePointer.Invalid; } d++; di++; } } Thread.Sleep(90 + ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 20)); } } catch (Exception error)//abort etc.. { m_Errors.Enqueue(error.ToMessageWithType()); } }); m_Traxers.Add(context); thread.Start(context); added++; } if (added > 0) { log("{0} added {1} threads".Args(DateTime.Now, added)); } var removed = 0; while ((!chkTraxer.Checked && m_Traxers.Count > 0) || m_Traxers.Count > __threadCount) { m_Traxers[0].STOP = true; m_Traxers.RemoveAt(0); removed++; } if (removed > 0) { log("{0} removed {1} threads".Args(DateTime.Now, removed)); } }