Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.openjdk.jol.operations;
import org.openjdk.jol.Operation;
import org.openjdk.jol.datamodel.DataModel;
import org.openjdk.jol.datamodel.X86_32_DataModel;
import org.openjdk.jol.datamodel.X86_64_COOPS_DataModel;
import org.openjdk.jol.datamodel.X86_64_DataModel;
import org.openjdk.jol.heap.HeapDumpException;
import org.openjdk.jol.heap.HeapDumpReader;
import org.openjdk.jol.info.ClassData;
import org.openjdk.jol.info.FieldData;
import org.openjdk.jol.layouters.HotSpotLayouter;
import org.openjdk.jol.layouters.Layouter;
import org.openjdk.jol.util.Multiset;
import java.io.File;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import static java.lang.System.out;
/**
* @author Aleksey Shipilev
*/
public class StringCompress implements Operation {
static final String DO_MODE = System.getProperty("mode", "estimates");
static final DataModel[] DATA_MODELS = new DataModel[]{
new X86_32_DataModel(),
new X86_64_DataModel(),
new X86_64_COOPS_DataModel(),
new X86_64_COOPS_DataModel(16)
};
@Override
public String label() {
return "string-compress";
}
@Override
public String description() {
return "Consume the heap dumps and figures out the savings attainable with compressed strings.";
}
public void run(String... args) throws Exception {
if (args.length == 0) {
System.err.println("Expected one or more heap dump file names.");
return;
}
if (DO_MODE.equalsIgnoreCase("histo")) {
out.printf("%15s, %15s, %15s, %s%n",
"\"size\"", "\"compressible\"", "\"non-compressible\"", "\"hprof file\"");
} else if (DO_MODE.equalsIgnoreCase("estimates")) {
out.printf("%15s, %15s, %15s, %15s, %15s, %15s, %15s, %15s, %15s, %s, %s%n",
"\"total\"", "\"String\"", "\"String+bool\"", "\"String+oop\"", "\"char[]-2b\"",
"\"char[]-1b\"", "\"char[]-1b-comp\"", "\"savings(same)\"", "\"savings(bool)\"", "\"savings(oop)\"", "\"hprof file\"", "\"model\"");
}
List> res = new ArrayList>();
ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
for (String arg : args) {
res.add(service.submit(new Worker(arg)));
}
for (int i = 0; i < res.size(); i++) {
Future> f = res.get(i);
try {
f.get();
} catch (ExecutionException e) {
e.getCause().printStackTrace(System.err);
// and then ignore
}
}
service.shutdown();
}
public static class Worker implements Callable