Esempio n. 1
0
        public virtual void Test002()
        {
            var b          = 10;
            var iterations = 10000;
            var table      = new AccurateIntegerLogarithmTool(b);
            var rndMth     = new Random();
            var rndAcc     = new Random();

            var timerMth = Stopwatch.StartNew();

            for (int sm = 0; sm < iterations; sm++)
            {
                var x = Math.Log(rndMth.Next(), b);
            }
            timerMth.Stop();

            var timerAcc = Stopwatch.StartNew();

            for (int sa = 0; sa < iterations; sa++)
            {
                var x = table.Log(rndAcc.Next());
            }
            timerAcc.Stop();

            Console.WriteLine("Math.Log completed in {0} ticks", timerMth.ElapsedTicks);
            Console.WriteLine("Accurate Integer Logarithm completed in {0} ticks", timerAcc.ElapsedTicks);
        }
 public void Init(long ts, long attr, long bucketSendLimit, int attritionBase, AccurateIntegerLogarithmTool logTool)
 {
     SkippedCount   = 0;
     ReceivedDate   = ts;
     ReceivedCount  = 0;
     AttritionCount = attr;
     SendLimit      = Math.Max(1L, bucketSendLimit / logTool.Log(AttritionCount + attritionBase));
     IsValid        = true;
 }
        public string PrettyPrintTree()
        {
            var result = new StringBuilder();

            result.AppendFormat("Interval Tree (array={0}) (depth>={1})", _nodes.Length, ((int)logBase2.Log(_nodes.Length)));
            result.AppendLine();


            PrettyPrintTree(result, 0);

            return(result.ToString());
        }
        public virtual void Test006()
        {
            ulong b     = 6;
            var   table = new AccurateIntegerLogarithmTool((int)b);

            ulong i = (ulong)b;

            for (uint j = 1; j < table.MaxOutput; j++)
            {
                Assert.AreEqual(j, table.Log(i));
                i *= b;
            }
        }