Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportTransactionStatistics()
        public virtual void ReportTransactionStatistics()
        {
            KernelTransactionImplementation transaction = newTransaction(100);

            KernelTransactionImplementation.Statistics statistics = new KernelTransactionImplementation.Statistics(transaction, new AtomicReference <CpuClock>(new ThreadBasedCpuClock()), new AtomicReference <HeapAllocation>(new ThreadBasedAllocation()));
            PredictablePageCursorTracer tracer = new PredictablePageCursorTracer();

            statistics.Init(2, tracer);

            assertEquals(2, statistics.CpuTimeMillis());
            assertEquals(2, statistics.HeapAllocatedBytes());
            assertEquals(1, statistics.TotalTransactionPageCacheFaults());
            assertEquals(4, statistics.TotalTransactionPageCacheHits());
            statistics.AddWaitingTime(1);
            assertEquals(1, statistics.GetWaitingTimeNanos(0));

            statistics.Reset();

            statistics.Init(4, tracer);
            assertEquals(4, statistics.CpuTimeMillis());
            assertEquals(4, statistics.HeapAllocatedBytes());
            assertEquals(2, statistics.TotalTransactionPageCacheFaults());
            assertEquals(6, statistics.TotalTransactionPageCacheHits());
            assertEquals(0, statistics.GetWaitingTimeNanos(0));
        }
Exemplo n.º 2
0
        public TransactionExecutionStatistic(KernelTransactionImplementation tx, SystemNanoClock clock, long startTimeMillis)
        {
            long nowMillis = clock.Millis();
            long nowNanos  = clock.Nanos();

            KernelTransactionImplementation.Statistics statistics = tx.GetStatistics();
            this._waitTimeMillis       = NANOSECONDS.toMillis(statistics.GetWaitingTimeNanos(nowNanos));
            this._heapAllocatedBytes   = NullIfNegative(statistics.HeapAllocatedBytes());
            this._directAllocatedBytes = NullIfNegative(statistics.DirectAllocatedBytes());
            this._cpuTimeMillis        = NullIfNegative(statistics.CpuTimeMillis());
            this._pageFaults           = statistics.TotalTransactionPageCacheFaults();
            this._pageHits             = statistics.TotalTransactionPageCacheHits();
            this._elapsedTimeMillis    = nowMillis - startTimeMillis;
            this._idleTimeMillis       = this._cpuTimeMillis != null ? _elapsedTimeMillis - this._cpuTimeMillis - _waitTimeMillis : null;
        }