Search in sources :

Example 16 with OModifiableInteger

use of com.orientechnologies.common.types.OModifiableInteger in project orientdb by orientechnologies.

the class OSessionStoragePerformanceStatisticTest method testReadFromCache.

public void testReadFromCache() {
    final OModifiableInteger increment = new OModifiableInteger();
    OSessionStoragePerformanceStatistic sessionStoragePerformanceStatistic = new OSessionStoragePerformanceStatistic(100, new OSessionStoragePerformanceStatistic.NanoTimer() {

        private long counter = 0;

        @Override
        public long getNano() {
            return counter += increment.getValue();
        }
    }, -1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache(), 0);
    sessionStoragePerformanceStatistic.startCommitTimer();
    for (int i = 0; i < 50; i++) {
        increment.setValue(50);
        sessionStoragePerformanceStatistic.startComponentOperation("c1po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
        sessionStoragePerformanceStatistic.startComponentOperation("c1po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
        sessionStoragePerformanceStatistic.startPageReadFromCacheTimer();
        sessionStoragePerformanceStatistic.stopPageReadFromCacheTimer();
        increment.setValue(150);
        //c2po inside of c1po
        sessionStoragePerformanceStatistic.startComponentOperation("c2po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
        sessionStoragePerformanceStatistic.startPageReadFromCacheTimer();
        sessionStoragePerformanceStatistic.stopPageReadFromCacheTimer();
        //c2po
        sessionStoragePerformanceStatistic.completeComponentOperation();
        //c1po first
        sessionStoragePerformanceStatistic.completeComponentOperation();
        //c1po last
        sessionStoragePerformanceStatistic.completeComponentOperation();
    }
    increment.setValue(100);
    for (int i = 0; i < 50; i++) {
        sessionStoragePerformanceStatistic.startPageReadFromCacheTimer();
        sessionStoragePerformanceStatistic.stopPageReadFromCacheTimer();
    }
    sessionStoragePerformanceStatistic.stopCommitTimer();
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation("c3po"), -1);
    sessionStoragePerformanceStatistic.startComponentOperation("c4po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    sessionStoragePerformanceStatistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    sessionStoragePerformanceStatistic.completeComponentOperation();
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation(null), -1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation("c1po"), 2);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation("c2po"), 1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation("c3po"), 0);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation("c4po"), -1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesPerOperation("c5po"), -1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache(), 150);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache(null), 150);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache("c1po"), 100);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache("c2po"), 50);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache("c3po"), 0);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getAmountOfPagesReadFromCache("c4po"), -1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getReadSpeedFromCacheInPages(), 10000000);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getReadSpeedFromCacheInPages(null), 10000000);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getReadSpeedFromCacheInPages("c1po"), 10000000);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getReadSpeedFromCacheInPages("c2po"), 6666666);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getReadSpeedFromCacheInPages("c3po"), -1);
    Assert.assertEquals(sessionStoragePerformanceStatistic.getReadSpeedFromCacheInPages("c4po"), -1);
    final ODocument doc = sessionStoragePerformanceStatistic.toDocument();
    Assert.assertEquals(doc.field("amountOfPagesReadFromCache"), 150L);
    Assert.assertEquals(doc.field("readSpeedFromCacheInPages"), 10000000L);
    final ODocument docC1PO = doc.<Map<String, ODocument>>field("dataByComponent").get("c1po");
    Assert.assertEquals(docC1PO.field("amountOfPagesReadFromCache"), 100L);
    Assert.assertEquals(docC1PO.field("readSpeedFromCacheInPages"), 10000000L);
    Assert.assertEquals(docC1PO.field("amountOfPagesPerOperation"), 2L);
    final ODocument docC2PO = doc.<Map<String, ODocument>>field("dataByComponent").get("c2po");
    Assert.assertEquals(docC2PO.field("amountOfPagesReadFromCache"), 50L);
    Assert.assertEquals(docC2PO.field("readSpeedFromCacheInPages"), 6666666L);
    Assert.assertEquals(docC2PO.field("amountOfPagesPerOperation"), 1L);
}
Also used : OModifiableInteger(com.orientechnologies.common.types.OModifiableInteger) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 17 with OModifiableInteger

use of com.orientechnologies.common.types.OModifiableInteger in project orientdb by orientechnologies.

the class OSessionStoragePerformanceStatisticTest method testCleanOnSnapshot.

public void testCleanOnSnapshot() {
    final OModifiableInteger counter = new OModifiableInteger(-100);
    OSessionStoragePerformanceStatistic statistic = new OSessionStoragePerformanceStatistic(200, new OSessionStoragePerformanceStatistic.NanoTimer() {

        @Override
        public long getNano() {
            counter.increment(100);
            return counter.getValue();
        }
    }, 200);
    OSessionStoragePerformanceStatistic.PerformanceCountersHolder performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    //100
    statistic.incrementPageAccessOnCacheLevel(false);
    counter.setValue(0);
    //100
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    //200-clear
    statistic.incrementPageAccessOnCacheLevel(true);
    counter.setValue(100);
    //200
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    //300
    statistic.incrementPageAccessOnCacheLevel(true);
    counter.setValue(200);
    //300
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    //400 - clear
    statistic.incrementPageAccessOnCacheLevel(true);
    counter.setValue(300);
    //400
    statistic.completeComponentOperation();
    statistic.pushSystemCounters(performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getCacheHits(), 100);
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushComponentCounters("c3po", performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getCacheHits(), 100);
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(300);
    //400
    statistic.startPageReadFromCacheTimer();
    //500
    statistic.stopPageReadFromCacheTimer();
    counter.setValue(400);
    //500
    statistic.startPageReadFromCacheTimer();
    //600 - clear
    statistic.stopPageReadFromCacheTimer();
    counter.setValue(500);
    //600
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(500);
    //600
    statistic.startPageReadFromCacheTimer();
    counter.increment(100);
    //800 - clear
    statistic.stopPageReadFromCacheTimer();
    counter.setValue(700);
    //900
    statistic.completeComponentOperation();
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushSystemCounters(performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getAmountOfPagesReadFromCache(), 1);
    Assert.assertEquals(performanceCountersHolder.getReadSpeedFromCacheInPages(), 5000000);
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushComponentCounters("c3po", performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getAmountOfPagesReadFromCache(), 1);
    Assert.assertEquals(performanceCountersHolder.getReadSpeedFromCacheInPages(), 5000000);
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(700);
    //800
    statistic.startPageReadFromFileTimer();
    //900
    statistic.stopPageReadFromFileTimer(1);
    counter.setValue(800);
    //900
    statistic.startPageReadFromFileTimer();
    //1000 - clear
    statistic.stopPageReadFromFileTimer(1);
    counter.setValue(900);
    //1000
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(900);
    //1000
    statistic.startPageReadFromFileTimer();
    //1100
    statistic.stopPageReadFromFileTimer(2);
    //1200 - clear
    statistic.completeComponentOperation();
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushSystemCounters(performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getAmountOfPagesReadFromFile(), 2);
    Assert.assertEquals(performanceCountersHolder.getReadSpeedFromFileInPages(), 20000000);
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushComponentCounters("c3po", performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getAmountOfPagesReadFromFile(), 2);
    Assert.assertEquals(performanceCountersHolder.getReadSpeedFromFileInPages(), 20000000);
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(1100);
    //1200
    statistic.startPageWriteInCacheTimer();
    //1300
    statistic.stopPageWriteInCacheTimer();
    counter.setValue(1200);
    //1300
    statistic.startPageWriteInCacheTimer();
    //1400 - clear
    statistic.stopPageWriteInCacheTimer();
    counter.setValue(1300);
    //1400
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(1300);
    //1400
    statistic.startPageWriteInCacheTimer();
    counter.increment(100);
    //1600 - clear
    statistic.stopPageWriteInCacheTimer();
    counter.setValue(1500);
    //1600
    statistic.completeComponentOperation();
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushSystemCounters(performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getAmountOfPagesWrittenInCache(), 1);
    Assert.assertEquals(performanceCountersHolder.getWriteSpeedInCacheInPages(), 5000000);
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushComponentCounters("c3po", performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getAmountOfPagesWrittenInCache(), 1);
    Assert.assertEquals(performanceCountersHolder.getWriteSpeedInCacheInPages(), 5000000);
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(1500);
    //1600
    statistic.startCommitTimer();
    //1700
    statistic.stopCommitTimer();
    counter.setValue(1600);
    //1700
    statistic.startCommitTimer();
    //1800 - clear
    statistic.stopCommitTimer();
    counter.setValue(1700);
    //1800
    statistic.completeComponentOperation();
    statistic.startComponentOperation("c3po", OSessionStoragePerformanceStatistic.ComponentType.GENERAL);
    counter.setValue(1600);
    //1700
    statistic.startCommitTimer();
    counter.increment(100);
    //1900
    statistic.stopCommitTimer();
    //2000 - clear
    statistic.completeComponentOperation();
    performanceCountersHolder = new OSessionStoragePerformanceStatistic.PerformanceCountersHolder();
    statistic.pushSystemCounters(performanceCountersHolder);
    Assert.assertEquals(performanceCountersHolder.getCommitTime(), 200);
}
Also used : OModifiableInteger(com.orientechnologies.common.types.OModifiableInteger)

Aggregations

OModifiableInteger (com.orientechnologies.common.types.OModifiableInteger)17 Change (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeRidBag.Change)4 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)3 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OSBTreeRidBag (com.orientechnologies.orient.core.db.record.ridbag.sbtree.OSBTreeRidBag)1 OBonsaiBucketPointer (com.orientechnologies.orient.core.index.sbtreebonsai.local.OBonsaiBucketPointer)1 ORecord (com.orientechnologies.orient.core.record.ORecord)1 OStorageProxy (com.orientechnologies.orient.core.storage.OStorageProxy)1 ORecordSerializationContext (com.orientechnologies.orient.core.storage.impl.local.paginated.ORecordSerializationContext)1 ORidBagUpdateSerializationOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.ORidBagUpdateSerializationOperation)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1