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);
        }
Esempio n. 2
0
        public void TestResetEsentStopwatch()
        {
            var stopwatch = EsentStopwatch.StartNew();

            stopwatch.Stop();
            stopwatch.Reset();
        }
Esempio n. 3
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 TestResetEsentStopwatch()
        {
            var stopwatch = EsentStopwatch.StartNew();

            stopwatch.Stop();
            stopwatch.Reset();
            Assert.AreEqual(TimeSpan.Zero, stopwatch.Elapsed);
        }
Esempio n. 5
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. 6
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. 7
0
 public void TestStartNewAndStopEsentStopwatch()
 {
     var stopwatch = EsentStopwatch.StartNew();
     stopwatch.Stop();
 }