To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 961c1787 authored by john's avatar john
Browse files

removed src/org/dacapo/harness which should have been moved with the hg rename command

parent 47353f7b
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
//import org.eclipse.core.runtime.adaptor.EclipseStarter;
import java.lang.reflect.Method;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Eclipse.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Eclipse extends Benchmark {
static final String WKSP_DIRECTORY_RELATIVE_TO_SCRATCH = "workspace";
static final String PLUGIN_ID = "org.dacapo.eclipse.Harness";
static final String OSGI_BOOTSTRAP_JAR = "eclipse" + File.separator + "plugins" + File.separator + "org.eclipse.osgi_3.5.1.R35x_v20090827.jar";
static String oldJavaHome = null;
static Eclipse eclipse;
static String size;
private final Method isRunning;
private final Method run;
private final Method shutdown;
public Eclipse(Config config, File scratch) throws Exception {
super(config, scratch, false);
Class<?> clazz = Class.forName("org.eclipse.core.runtime.adaptor.EclipseStarter", true, loader);
this.method = clazz.getMethod("startup", String[].class, Runnable.class);
this.isRunning = clazz.getMethod("isRunning");
this.run = clazz.getMethod("run", Object.class);
this.shutdown = clazz.getMethod("shutdown");
}
public void preIteration(String size) throws Exception {
super.preIteration(size);
if (!((Boolean) isRunning.invoke(null, (Object[]) null)).booleanValue()) {
startup(size);
}
setJavaHomeIfRequired();
try {
String[] largePluginArgs = { "large", "unzip" };
String[] pluginArgs = { "unzip" };
run.invoke(null, new Object[] { size.equals("large") ? largePluginArgs : pluginArgs });
} catch (Exception e) {
e.printStackTrace();
}
}
public void iterate(String size) throws Exception {
try {
// String[] pluginArgs = {"setup", "alltests" }; // get this from the bm
// config
String[] pluginArgs = config.getArgs(size);
run.invoke(null, new Object[] { pluginArgs });
} catch (Exception e) {
e.printStackTrace();
}
}
public void postIteration(String size) throws Exception {
try {
String[] pluginArgs = { "teardown" };
run.invoke(null, new Object[] { pluginArgs });
} catch (Exception e) {
e.printStackTrace();
}
super.postIteration(size);
restoreJavaHomeIfRequired();
}
public void cleanup() {
try {
shutdown.invoke(null, (Object[]) null);
} catch (Exception e) {
e.printStackTrace();
}
}
private void startup(String size) {
try {
System.setProperty("osgi.os", "linux");
System.setProperty("osgi.ws", "gtk");
System.setProperty("osgi.arch", "x86");
System.setProperty("osgi.install.area", "file:" + fileInScratch("eclipse/"));
System.setProperty("osgi.noShutdown", "true");
System.setProperty("osgi.framework", "file:" + fileInScratch(OSGI_BOOTSTRAP_JAR));
setJavaHomeIfRequired();
String[] args = new String[4];
args[0] = "-data"; // identify the workspace
args[1] = fileInScratch(WKSP_DIRECTORY_RELATIVE_TO_SCRATCH);
args[2] = "-application"; // identify the plugin
args[3] = PLUGIN_ID;
method.invoke(null, new Object[] { args, null });
} catch (Exception e) {
e.printStackTrace();
}
}
private void setJavaHomeIfRequired() {
String eclipseJavaHome = System.getProperty("eclipse.java.home");
if (eclipseJavaHome != null) {
oldJavaHome = System.getProperty("java.home");
System.setProperty("java.home", eclipseJavaHome);
}
}
private void restoreJavaHomeIfRequired() {
if (oldJavaHome != null)
System.setProperty("java.home", oldJavaHome);
}
}
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Fop.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Fop extends Benchmark {
private String[] args;
public Fop(Config config, File scratch) throws Exception {
super(config, scratch);
Class<?> clazz = Class.forName("org.apache.fop.cli.Main", true, loader);
this.method = clazz.getMethod("startFOP", new Class[] { String[].class });
}
@Override
protected void prepare(String size) throws Exception {
super.prepare(size);
args = config.preprocessArgs(size, scratch);
/* Retarget input/output files into scratch directory */
for (int i = 0; i < args.length; i++)
if (args[i].charAt(0) != '-')
args[i] = fileInScratch(args[i]);
}
public void iterate(String size) throws Exception {
method.invoke(null, new Object[] { args });
}
}
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.lang.reflect.Method;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Jython.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Jython extends Benchmark {
private Method pySetArgsMethod;
public Jython(Config config, File scratch) throws Exception {
super(config, scratch);
Class<?> clazz = Class.forName("org.python.util.jython", true, loader);
this.method = clazz.getMethod("main", String[].class);
Class<?> pyClass = Class.forName("org.python.core.PySystemState", true, loader);
pySetArgsMethod = pyClass.getMethod("setArgv", String[].class);
System.setProperty("python.home", fileInScratch("jython"));
System.setProperty("python.cachedir", fileInScratch("cachedir"));
System.setProperty("python.verbose", "warning");
useBenchmarkClassLoader();
try {
method.invoke(null, (Object) new String[] { fileInScratch("jython/noop.py") });
} finally {
revertClassLoader();
}
}
/**
* jython.main doesn't expect to be called multiple times, so we've hacked
* Py.setArgv to allow us to reset the command line arguments that the python
* script sees. Hence the Py.setArgv call, followed by the jython.main call.
*/
public void iterate(String size) throws Exception {
String[] args = config.preprocessArgs(size, scratch);
pySetArgsMethod.invoke(null, (Object) args);
method.invoke(null, (Object) args);
}
public void cleanup() {
super.cleanup();
deleteTree(new File(scratch, "cachedir"));
}
}
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.lang.reflect.Constructor;
import org.dacapo.harness.Benchmark;
import org.dacapo.harness.DacapoException;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Luindex.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Luindex extends Benchmark {
private final Object benchmark;
public Luindex(Config config, File scratch) throws Exception {
super(config, scratch);
Class<?> clazz = Class.forName("org.dacapo.luindex.Index", true, loader);
this.method = clazz.getMethod("main", File.class, String[].class);
Constructor<?> cons = clazz.getConstructor(File.class);
useBenchmarkClassLoader();
try {
benchmark = cons.newInstance(scratch);
} finally {
revertClassLoader();
}
}
public void cleanup() {
if (!getPreserve()) {
deleteTree(new File(scratch, "luindex"));
}
}
public void preIteration(String size) {
if (getPreserve() && getIteration() > 1) {
deleteTree(new File(scratch, "index"));
}
}
/**
* Index all text files under a directory.
*/
public void iterate(String size) throws Exception {
if (getVerbose())
System.out.println("luindex benchmark starting");
String[] args = config.preprocessArgs(size, scratch);
final File INDEX_DIR = new File(scratch, "index");
if (INDEX_DIR.exists()) {
System.out.println("Cannot save index to '" + INDEX_DIR + "' directory, please delete it first");
throw new DacapoException("Cannot write to index directory");
}
method.invoke(benchmark, INDEX_DIR, args);
}
public void postIteration(String size) {
if (!getPreserve()) {
deleteTree(new File(scratch, "index"));
}
}
}
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.lang.reflect.Constructor;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Lusearch.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Lusearch extends org.dacapo.harness.Benchmark {
private final Object benchmark;
public Lusearch(Config config, File scratch) throws Exception {
super(config, scratch, false);
Class<?> clazz = Class.forName("org.dacapo.lusearch.Search", true, loader);
this.method = clazz.getMethod("main", String[].class);
Constructor<?> cons = clazz.getConstructor();
useBenchmarkClassLoader();
try {
benchmark = cons.newInstance();
} finally {
revertClassLoader();
}
}
@Override
public void iterate(String size) throws Exception {
method.invoke(benchmark, (Object) (config.preprocessArgs(size, scratch)));
}
}
/*
* Copyright (c) 2005, 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Pmd.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Pmd extends Benchmark {
String[] args;
public Pmd(Config config, File scratch) throws Exception {
super(config, scratch);
Class<?> clazz = Class.forName("net.sourceforge.pmd.PMD", true, loader);
this.method = clazz.getMethod("main", String[].class);
/*
* Explicitly set some properties that control factory methods
*
* Leaving it to the standard methods of resolving at runtime can lead to
* testing different implementations on different platforms.
*
* It's always possible that there are additional properties that need to be
* set.
*/
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
}
public void prepare(String size) {
args = config.getArgs(size);
if (args[0].charAt(0) == '@')
args[0] = collectFilesFromFile(fileInScratch(args[0].substring(1)));
for (int i = 2; i < args.length; i++) {
if (args[i].charAt(0) != '-')
args[i] = fileInScratch(args[i]);
}
}
public void iterate(String size) throws Exception {
method.invoke(null, (Object) args);
}
private String collectFilesFromFile(String inputFileName) {
try {
java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(new FileInputStream(inputFileName)));
List<File> files = new ArrayList<File>();
for (String l = reader.readLine(); l != null; l = reader.readLine()) {
files.add(new File(scratch, l));
}
return commaSeparate(files);
} catch (FileNotFoundException e) {
throw new RuntimeException("File " + inputFileName + " error: " + e);
} catch (java.io.IOException e) {
throw new RuntimeException("File " + inputFileName + " error: " + e);
}
}
private static String commaSeparate(List<File> list) {
String result = "";
for (Iterator<File> i = list.iterator(); i.hasNext();) {
String s = i.next().getPath();
result += s;
if (i.hasNext())
result += ",";
}
return result;
}
}
/*
* Copyright (c) 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.dacapo.parser.Config;
/**
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Sunflow.java 738 2009-12-24 00:19:36Z steveb-oss $
*/
public class Sunflow extends org.dacapo.harness.Benchmark {
private final Constructor<?> constructor;
private Object sunflow;
private final Method beginMethod;
private final Method endMethod;
public Sunflow(Config config, File scratch) throws Exception {
super(config, scratch, false);
Class<?> clazz = Class.forName("org.sunflow.Benchmark", true, loader);
this.method = clazz.getMethod("kernelMain");
this.beginMethod = clazz.getMethod("kernelBegin");
this.endMethod = clazz.getMethod("kernelEnd");
this.constructor = clazz.getConstructor(int.class, boolean.class, boolean.class, boolean.class, int.class);
}
/** Do one-time prep such as unziping data. In our case, do nothing. */
protected void prepare() {
}
/**
* Code to execute prior to each iteration OUTSIDE the timing loop. In this
* case we create a new instance of a Sunflow benchmark, which sets up basic
* data structures.
*
* @param size The "size" of the iteration (small, default, large)
*/
public void preIteration(String size) throws Exception {
String[] args = config.preprocessArgs(size, scratch);
useBenchmarkClassLoader();
try {
sunflow = constructor.newInstance(Integer.parseInt(args[0]), false, false, false, config.getThreadCount(size));
beginMethod.invoke(sunflow);
} finally {
revertClassLoader();
}
}
/**
* Perform a single iteration of the benchmark.
*
* @param size The "size" of the iteration (small, default, large)
*/
public void iterate(String size) throws Exception {
method.invoke(sunflow);
}
/**
* Validate the output of the benchmark, OUTSIDE the timing loop.
*
* @param size The "size" of the iteration (small, default, large)
*/
public boolean validate(String size) {
if (!getValidate())
return true;
try {
useBenchmarkClassLoader();
try {
endMethod.invoke(sunflow);
} finally {
revertClassLoader();
}
} catch (RuntimeException e) {
System.err.println(e.getMessage());
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}
return super.validate(size);
}
}
/*
* Copyright (c) 2009 The Australian National University.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0.
* You may obtain the license at
*
* http://www.opensource.org/licenses/apache2.0.php
*/
package org.dacapo.harness;
import java.io.File;
import java.lang.reflect.Constructor;
import org.dacapo.harness.Benchmark;
import org.dacapo.parser.Config;
/**
* Benchmark harness for the Tomcat benchmark
*
* @date $Date: 2009-12-24 11:19:36 +1100 (Thu, 24 Dec 2009) $
* @id $Id: Tomcat.java 738 2009-12-24 00:19:36Z steveb-oss $
*
*/
public class Tomcat extends Benchmark {
private static final int PORT = 7080;// Integer.valueOf(System.getProperty("dacapo.tomcat.port", "7080"));
private final Class<?> clazz;
private final Constructor<Runnable> clientConstructor;
private final Object controller;
/**
* Benchmark constructor - invoked reflectively by the harness.
*
* @param config Benchmark configuration object
* @param scratch Scratch directory
* @throws Exception When something goes wrong
*/
public Tomcat(Config config, File scratch) throws Exception {
super(config, scratch, false);
this.clazz = Class.forName("org.dacapo.tomcat.Control", true, loader);
this.method = clazz.getMethod("exec", String.class);
/* Create a constructor for the tomcat controller */
Constructor<?> controlConstructor = clazz.getConstructor(File.class, ClassLoader.class, int.class);
this.controller = controlConstructor.newInstance(scratch, loader, PORT);
/* Create a constructor for the tomcat client */
@SuppressWarnings("unchecked")
Class<Runnable> clientClass = (Class<Runnable>) Class.forName("org.dacapo.tomcat.Client", true, loader);
this.clientConstructor = clientClass.getConstructor(File.class, int.class, int.class, boolean.class, int.class);
}
/**
* One-off setup
*/
@Override
public void prepare(String size) throws Exception {
super.prepare(size);
try {