Esempio n. 1
0
        public virtual void TestTiming()
        {
            Timing t = new Timing();

            SleepTen();
            long val2 = t.ReportNano();

            NUnit.Framework.Assert.IsTrue(string.Format("Wrong nanosleep %d", val2), val2 < 30_000_000);
            NUnit.Framework.Assert.IsTrue(string.Format("Wrong nanosleep %d", val2), val2 > 3_000_000);
            SleepTen();
            long val = t.Report();

            // System.err.println(val);
            NUnit.Framework.Assert.AreEqual("Wrong sleep", 20, val, 20);
            for (int i = 0; i < 8; i++)
            {
                SleepTen();
            }
            long val3 = t.Report();

            NUnit.Framework.Assert.AreEqual("Wrong formatted time", new DecimalFormat("0.0").Format(0.1), Timing.ToSecondsString(val3));
        }