public void TestRunningStopwatchToString()
        {
            var stopwatch = new EsentStopwatch();

            stopwatch.Start();
            Assert.AreEqual("EsentStopwatch (running)", stopwatch.ToString());
        }
        public void TestJetThreadstatsToStringPerf()
        {
            var t = new JET_THREADSTATS
            {
                cPageReferenced = 10,
                cPageRead       = 5,
                cPagePreread    = 4,
                cPageDirtied    = 3,
                cPageRedirtied  = 2,
                cLogRecord      = 1,
                cbLogRecord     = 0,
            };

            // Call the method once to make sure it is compiled.
            string ignored = t.ToString();

            const int      N = 100000;
            EsentStopwatch s = EsentStopwatch.StartNew();

            for (int i = 0; i < N; ++i)
            {
                ignored = t.ToString();
            }

            s.Stop();

            double ms = Math.Max(1, s.Elapsed.Milliseconds);

            EseInteropTestHelper.ConsoleWriteLine("{0} calls in {1} ({2} ms/call)", N, s.Elapsed, ms / N);
        }
        public void TestStartAndStopEsentStopwatch()
        {
            var stopwatch = new EsentStopwatch();

            stopwatch.Start();
            stopwatch.Stop();
        }
Esempio n. 4
0
        public void TestResetEsentStopwatch()
        {
            var stopwatch = EsentStopwatch.StartNew();

            stopwatch.Stop();
            stopwatch.Reset();
        }
Esempio n. 5
0
        /// <summary>
        /// Perform and time the given action.
        /// </summary>
        /// <param name="name">The name of the action.</param>
        /// <param name="action">The operation to perform.</param>
        private static void TimeAction(string name, Action action)
        {
            var stopwatch = EsentStopwatch.StartNew();

            action();
            stopwatch.Stop();
            EseInteropTestHelper.ConsoleWriteLine("{0}: {1} ({2})", name, stopwatch.Elapsed, stopwatch.ThreadStats);
        }
        public void TestStoppedStopwatchToString()
        {
            var stopwatch = new EsentStopwatch();

            stopwatch.Start();
            stopwatch.Stop();
            Assert.AreEqual(stopwatch.Elapsed.ToString(), stopwatch.ToString());
        }
        public void TestResetEsentStopwatch()
        {
            var stopwatch = EsentStopwatch.StartNew();

            stopwatch.Stop();
            stopwatch.Reset();
            Assert.AreEqual(TimeSpan.Zero, stopwatch.Elapsed);
        }
Esempio n. 8
0
        /// <summary>
        /// Perform and time the given action.
        /// </summary>
        /// <param name="action">The operation to perform.</param>
        private static void TimeAction(Action action)
        {
            // Let other threads run before we start our test
            Thread.Sleep(1);
            var stopwatch = EsentStopwatch.StartNew();

            action();
            stopwatch.Stop();
            Console.WriteLine("{0} ({1})", stopwatch.Elapsed, stopwatch.ThreadStats);
        }
Esempio n. 9
0
        public void TestDictionaryLookupPerf()
        {
            const int NumIterations       = 200000;
            const int LookupsPerIteration = 5;

            var stopwatch = EsentStopwatch.StartNew();

            for (int i = 0; i < NumIterations; ++i)
            {
                JET_COLUMNID boolean = this.columnidDict["Boolean"];
                JET_COLUMNID int16   = this.columnidDict["Int16"];
                JET_COLUMNID @float  = this.columnidDict["Float"];
                JET_COLUMNID ascii   = this.columnidDict["Ascii"];
                JET_COLUMNID uint64  = this.columnidDict["Uint64"];
            }

            stopwatch.Stop();
            const double TotalLookups = NumIterations * LookupsPerIteration;
            double       lookupRate   = TotalLookups / stopwatch.Elapsed.Milliseconds;

            EseInteropTestHelper.ConsoleWriteLine("{0} lookups/millisecond", lookupRate);
        }
Esempio n. 10
0
 public void TestStartNewAndStopEsentStopwatch()
 {
     var stopwatch = EsentStopwatch.StartNew();
     stopwatch.Stop();
 }