示例#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));
        }
示例#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;
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution()
        public virtual void ReportQueryWaitingTimeToTransactionStatisticWhenFinishQueryExecution()
        {
            KernelTransactionImplementation transaction = mock(typeof(KernelTransactionImplementation));
            TxStateHolder txStateHolder  = mock(typeof(TxStateHolder));
            StorageReader storeStatement = mock(typeof(StorageReader));

            KernelTransactionImplementation.Statistics statistics = new KernelTransactionImplementation.Statistics(transaction, new AtomicReference <CpuClock>(CpuClock.NOT_AVAILABLE), new AtomicReference <HeapAllocation>(HeapAllocation.NOT_AVAILABLE));
            when(transaction.GetStatistics()).thenReturn(statistics);
            when(transaction.ExecutingQueries()).thenReturn(ExecutingQueryList.EMPTY);

            KernelStatement statement = new KernelStatement(transaction, txStateHolder, storeStatement, LockTracer.NONE, mock(typeof(StatementOperationParts)), new ClockContext(), EmptyVersionContextSupplier.EMPTY);

            statement.Acquire();

            ExecutingQuery query  = QueryWithWaitingTime;
            ExecutingQuery query2 = QueryWithWaitingTime;
            ExecutingQuery query3 = QueryWithWaitingTime;

            statement.StopQueryExecution(query);
            statement.StopQueryExecution(query2);
            statement.StopQueryExecution(query3);

            assertEquals(3, statistics.GetWaitingTimeNanos(1));
        }