Created
November 24, 2014 12:56
-
-
Save serkan-ozal/47593f810d95258c1a9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testToFindEntryCountFactor() { | |
final ICache cache = createCache(); | |
final Random random = new Random(); | |
final int size = 1000; | |
for (int i = 0; i < size; i++) { | |
cache.put(i, random.nextInt(size)); | |
} | |
/////////////////////////////////////////////////////////////////////////////////// | |
HazelcastServerCacheManager hscm = (HazelcastServerCacheManager) cacheManager; | |
EnterpriseCacheService ecs = (EnterpriseCacheService) hscm.getCacheService(); | |
int partitionCount = ecs.getNodeEngine().getPartitionService().getPartitionCount(); | |
/////////////////////////////////////////////////////////////////////////////////// | |
int totalSize = 0; | |
System.out.println(partitionCount); | |
for (int partitionId = 0; partitionId < partitionCount; partitionId++) { | |
ICacheRecordStore crs = ecs.getCacheRecordStore("/hz/" + cache.getName(), partitionId); | |
totalSize += crs.size(); | |
} | |
final int averageSize = (int) ((double) totalSize / (double)partitionCount); | |
System.out.println("log: Total size: " + totalSize + ", Average size: " + averageSize); | |
/////////////////////////////////////////////////////////////////////////////////// | |
double sizeDiffRatio = 0; | |
for (int partitionId = 0; partitionId < partitionCount; partitionId++) { | |
ICacheRecordStore crs = ecs.getCacheRecordStore("/hz/" + cache.getName(), partitionId); | |
sizeDiffRatio += (double) averageSize / (double) crs.size(); | |
} | |
final double averageSizeDiffRatio = sizeDiffRatio / partitionCount; | |
System.out.println("log: Total size diff ratio: " + sizeDiffRatio + | |
", Average size diff ratio: " + averageSizeDiffRatio); | |
/////////////////////////////////////////////////////////////////////////////////// | |
int deviation = 0; | |
for (int partitionId = 0; partitionId < partitionCount; partitionId++) { | |
ICacheRecordStore crs = ecs.getCacheRecordStore("/hz/" + cache.getName(), partitionId); | |
deviation += Math.pow((crs.size() - averageSize), 2); | |
} | |
final double variation = (double) deviation / (double) partitionCount; | |
final double standardDeviation = Math.sqrt(variation); | |
System.out.println("log: Variation: " + variation + ", Standard deviation: " + standardDeviation); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment