本文整理汇总了Java中org.openjdk.jol.info.GraphLayout类的典型用法代码示例。如果您正苦于以下问题:Java GraphLayout类的具体用法?Java GraphLayout怎么用?Java GraphLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphLayout类属于org.openjdk.jol.info包,在下文中一共展示了GraphLayout类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
ArrayList<Integer> al = new ArrayList<Integer>();
LinkedList<Integer> ll = new LinkedList<Integer>();
for (int i = 0; i < 1000; i++) {
Integer io = i; // box once
al.add(io);
ll.add(io);
}
al.trimToSize();
PrintWriter pw = new PrintWriter(out);
pw.println(GraphLayout.parseInstance(al).toFootprint());
pw.println(GraphLayout.parseInstance(ll).toFootprint());
pw.println(GraphLayout.parseInstance(al, ll).toFootprint());
pw.close();
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:21,代码来源:JOLSample_16_AL_LL.java
示例2: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
// allocate some objects to beef up generations
for (int c = 0; c < 1000000; c++) {
sink = new Object();
}
System.gc();
List<String> list = new ArrayList<String>();
for (int c = 0; c < 1000; c++) {
list.add("Key" + c);
}
for (int c = 1; c <= 10; c++) {
GraphLayout.parseInstance(list).toImage("list-" + c + ".png");
System.gc();
}
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:20,代码来源:JOLSample_22_Compaction.java
示例3: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
// allocate some objects to beef up generations
for (int c = 0; c < 1000000; c++) {
sink = new Object();
}
System.gc();
final int COUNT = 10000;
Object[] array = new Object[COUNT];
for (int c = 0; c < COUNT; c++) {
array[c] = new Object();
}
Object obj = array;
GraphLayout.parseInstance(obj).toImage("array-1-new.png");
for (int c = 2; c <= 5; c++) {
System.gc();
GraphLayout.parseInstance(obj).toImage("array-" + c + "-before.png");
}
for (int c = 0; c < COUNT; c++) {
if (Math.random() < 0.5) {
array[c] = null;
}
}
GraphLayout.parseInstance(obj).toImage("array-6-after.png");
for (int c = 7; c <= 10; c++) {
System.gc();
GraphLayout.parseInstance(obj).toImage("array-" + c + "-after-gc.png");
}
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:39,代码来源:JOLSample_23_Defragmentation.java
示例4: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
// allocate some objects to beef up generations
for (int c = 0; c < 1000000; c++) {
sink = new Object();
}
System.gc();
final int COUNT = 1000;
ConcurrentHashMap<Object, Object> chm = new ConcurrentHashMap<Object, Object>();
addElements(COUNT, chm);
GraphLayout.parseInstance(chm).toImage("chm-1-new.png");
for (int c = 2; c <= 5; c++) {
GraphLayout.parseInstance(chm).toImage("chm-" + c + "-gc.png");
System.gc();
}
addElements(COUNT, chm);
for (int c = 6; c <= 10; c++) {
GraphLayout.parseInstance(chm).toImage("chm-" + c + "-more-gc.png");
System.gc();
}
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:31,代码来源:JOLSample_24_Colocation.java
示例5: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
PrintWriter pw = new PrintWriter(System.out, true);
Map<Dummy, Void> map = new HashMap<Dummy, Void>();
map.put(new Dummy(1), null);
map.put(new Dummy(2), null);
System.gc();
pw.println(GraphLayout.parseInstance(map).toPrintable());
map.put(new Dummy(2), null);
map.put(new Dummy(2), null);
map.put(new Dummy(2), null);
map.put(new Dummy(2), null);
System.gc();
pw.println(GraphLayout.parseInstance(map).toPrintable());
for (int c = 0; c < 12; c++) {
map.put(new Dummy(2), null);
}
System.gc();
pw.println(GraphLayout.parseInstance(map).toPrintable());
pw.close();
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:31,代码来源:JOLSample_18_Layouts.java
示例6: printSize
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void printSize(final @NotNull Object object) {
System.out.println(String.format("%-30s(%-25s)\t %-10s\t%-10s\t%-10s\n",
object.toString(),
object.getClass(),
SimpleAgent.getObjectSize(object),
ObjectLayer.layout(object).instanceSize(),
GraphLayout.parseInstance(object).totalSize()
));
}
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:10,代码来源:Sample.java
示例7: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) {
new Container().printMe();
System.out.println(VMSupport.vmDetails());
System.out.println(ClassLayout.parseClass(Container.class).toPrintable());
System.out.println(GraphLayout.parseInstance(new Container()).toPrintable());
}
开发者ID:msteindorfer,项目名称:criterion,代码行数:9,代码来源:TestMemoryLayout.java
示例8: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
/** Run a test and output the memory footprint of the registry. */
@SuppressWarnings("PMD")
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Usage: perf <registry> <test>");
System.exit(1);
}
Registry registry = run(args[0], args[1]);
GraphLayout igraph = GraphLayout.parseInstance(registry);
System.out.println(igraph.toFootprint());
}
开发者ID:Netflix,项目名称:spectator,代码行数:14,代码来源:Main.java
示例9: checkMemoryUsage
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
private void checkMemoryUsage(Registry registry, long limit) {
GraphLayout graph = GraphLayout.parseInstance(registry);
long size = graph.totalSize();
String details = "memory use exceeds limit: " + size + " > " + limit + "\n\n" + graph.toFootprint();
//System.out.println(details);
Assert.assertTrue(details, size <= limit);
}
开发者ID:Netflix,项目名称:spectator,代码行数:8,代码来源:MemoryUseTest.java
示例10: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
log.info("various vm properties visible via the unsafe");
log.info(VMSupport.vmDetails());
log.info("memory layout based on class object at runtime");
log.info(ClassLayout.parseClass(CodableFieldInfo.class).toPrintable());
log.info("runtime footprint for the standard java string object for 'heylo friend'");
String sample = "heylo friend";
log.info(GraphLayout.parseInstance(sample).toFootprint());
}
开发者ID:addthis,项目名称:codec,代码行数:12,代码来源:JolExample.java
示例11: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
log.info("various vm properties visible via the unsafe");
log.info(VMSupport.vmDetails());
log.info("memory layout based on class object at runtime; should see 4 'free bytes' to spend");
log.info(ClassLayout.parseClass(ByteArrayReadOnlyAsciiBuf.class).toPrintable());
log.info("runtime footprint for the standard java string object for 'heylo friend'");
String sample = "heylo friend";
log.info(GraphLayout.parseInstance(sample).toFootprint());
log.info("runtime footprint for a ByteArrayReadOnlyUtfBuf object for 'heylo friend'");
ByteArrayReadOnlyUtfBuf utfBuf = new ByteArrayReadOnlyUtfBuf(sample);
log.info(GraphLayout.parseInstance(utfBuf).toFootprint());
}
开发者ID:addthis,项目名称:basis,代码行数:16,代码来源:ByteArrayCharBufJol.java
示例12: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
Map<String, String> chm = new ConcurrentHashMap<String, String>();
GraphLayout gl1 = GraphLayout.parseInstance(chm);
chm.put("Foo", "Bar");
GraphLayout gl2 = GraphLayout.parseInstance(chm);
chm.put("Foo2", "Bar2");
GraphLayout gl3 = GraphLayout.parseInstance(chm);
System.out.println(gl2.subtract(gl1).toPrintable());
System.out.println(gl3.subtract(gl2).toPrintable());
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:17,代码来源:JOLSample_24_Difference.java
示例13: main
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
out.println(VM.current().details());
PrintWriter pw = new PrintWriter(System.out, true);
// create links
L l1 = new L1();
L l2 = new L2();
L l3 = new L3();
L l4 = new L4();
L l5 = new L5();
L l6 = new L6();
// bind the ring
l1.bind(l2);
l2.bind(l3);
l3.bind(l4);
l4.bind(l5);
l5.bind(l6);
l6.bind(l1);
// current root
L r = l1;
// break all other roots
l1 = l2 = l3 = l4 = l5 = l6 = null;
long lastAddr = VM.current().addressOf(r);
pw.printf("Fresh object is at %x%n", lastAddr);
int moves = 0;
for (int i = 0; i < 100000; i++) {
// scan for L1 and determine it's address
L s = r;
while (!((s = s.link()) instanceof L1)) ;
long cur = VM.current().addressOf(s);
s = null;
// if L1 had moved, then probably the entire ring had also moved
if (cur != lastAddr) {
moves++;
pw.printf("*** Move %2d, L1 is at %x%n", moves, cur);
pw.println("*** Root is " + r.getClass());
pw.println(GraphLayout.parseInstance(r).toPrintable());
// select another link
Random random = new Random();
for (int c = 0; c < random.nextInt(100); c++) {
r = r.link();
}
lastAddr = cur;
}
// make garbage
for (int c = 0; c < 10000; c++) {
sink = new Object();
}
}
pw.close();
}
开发者ID:tianshuang,项目名称:jol-samples,代码行数:66,代码来源:JOLSample_20_Roots.java
示例14: printUsage
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
static void printUsage(Object obj) {
long total = GraphLayout.parseInstance(obj).totalSize();
long perItem = Math.round((double) (total) / SIZE);
System.out.println(String.format("%-30s: %-6d bytes\t(%-3d b/item)", obj.getClass(), total, perItem));
}
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:6,代码来源:MemoryUsage.java
示例15: testPercolationSize
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
@Test
public void testPercolationSize()
throws Exception {
long percolationSize = GraphLayout.parseInstance(p).totalSize();
assertThat(percolationSize, lessThanOrEqualTo(11 * size * size + 128 * size + 1024));
}
开发者ID:Alex-Diez,项目名称:Java-Algorithms,代码行数:7,代码来源:MemorySizeTest.java
示例16: testLoad
import org.openjdk.jol.info.GraphLayout; //导入依赖的package包/类
@Test
@Ignore
public void testLoad() throws SyntaxException {
int nbCaches = 10;
int nbElements = 500000;
CacheConfigurationBuilder<Long, byte[]> configurationBuilder = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, byte[].class,
newResourcePoolsBuilder().heap(nbElements, EntryUnit.ENTRIES).build());
CacheManagerBuilder<CacheManager> cacheManagerBuilder = newCacheManagerBuilder();
for (int i = 0; i < nbCaches; i++) {
cacheManagerBuilder = cacheManagerBuilder.withCache("cache" + i, configurationBuilder.build());
}
CacheManager cacheManager = cacheManagerBuilder.build(true);
CacheDefinition<Long, byte[]>[] cacheDefinitions = new CacheDefinition[nbCaches];
CacheConfig<Long, byte[]> cacheConfig = cacheConfig(Long.class, byte[].class);
for (int i = 0; i < nbCaches; i++) {
String alias = "cache" + i;
cacheDefinitions[i] = new CacheDefinition<Long, byte[]>(alias, cacheManager.getCache(alias, Long.class, byte[].class));
cacheConfig.cache(alias, cacheManager.getCache(alias, Long.class, byte[].class));
}
ConcurrencyConfig concurrency = ConcurrencyConfig.concurrencyConfig()
.threads(4).timeout(50, MINUTES);
ObjectGenerator<Long> keyGenerator = new LongGenerator();
ObjectGenerator<byte[]> valueGenerator = fixedLengthByteArray(1000);
System.out.println("----------> Warm up phase");
ScenarioRun run = Runner.setUp(
scenario("Warm up phase").exec(
put(keyGenerator, valueGenerator, sequentially(), asList(cacheDefinitions)),
get(Long.class, byte[].class).using(keyGenerator, valueGenerator).sequentially(),
remove(Long.class, byte[].class).using(keyGenerator, valueGenerator).sequentially(),
putIfAbsent(Long.class, byte[].class).using(keyGenerator, valueGenerator).sequentially()
))
.executed(times(nbElements))
.config(concurrency, ReportingConfig.report(EhcacheResult.class).log(text()))
.config(cacheConfig);
run.start();
GraphLayout graphLayout = GraphLayout.parseInstance(run);
System.out.println(graphLayout.totalSize());
System.out.println("----------> Done");
cacheManager.close();
}
开发者ID:aurbroszniowski,项目名称:Rainfall-ehcache,代码行数:48,代码来源:PerfTest3.java
注:本文中的org.openjdk.jol.info.GraphLayout类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论