public void IntMathUpperPower() { Aver.AreEqual(1024, IntMath.UpperPow(1024, 2)); Aver.AreEqual(9, IntMath.UpperPow(9, 3)); Aver.AreEqual(27, IntMath.UpperPow(11, 3)); Aver.AreEqual(16, IntMath.UpperPow(14, 2)); Aver.AreEqual(16, IntMath.UpperPow(15, 2)); Aver.AreEqual(16, IntMath.UpperPow(16, 2)); Aver.AreEqual(4, IntMath.UpperPow(3, 2)); }
/// <summary> /// Reset the internal state of the throttling strategy /// </summary> public override void Reset() { int maxSeconds = (int)IntMath.UpperPow(m_BucketsPerSec * m_Interval, 2); m_LogBucketsSec = IntMath.Log(m_BucketsPerSec, 2); m_BucketCount = maxSeconds * m_BucketsPerSec; m_BucketMask = m_BucketCount - 1; m_BucketsInterval = m_Interval << m_LogBucketsSec; // must be power of two Debug.Assert((m_BucketCount & (m_BucketCount - 1)) == 0); m_Buckets = new double[m_BucketCount]; Array.Clear(m_Buckets, 0, m_Buckets.Length); m_LastTimeBucket = 0; m_Sum = 0; }