gate.util.Benchmark Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gate-core Show documentation
Show all versions of gate-core Show documentation
GATE - general achitecture for text engineering - is open source
software capable of solving almost any text processing problem. This
artifact enables you to embed the core GATE Embedded with its essential
dependencies. You will able to use the GATE Embedded API and load and
store GATE XML documents. This artifact is the perfect dependency for
CREOLE plugins or for applications that need to customize the GATE
dependencies due to confict with their own dependencies or for lower
footprint.
The newest version!
/*
* Benchmark.java
*
* Copyright (c) 1995-2012, The University of Sheffield. See the file
* COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
*
* This file is part of GATE (see http://gate.ac.uk/), and is free
* software, licenced under the GNU Library General Public License,
* Version 2, June 1991 (in the distribution as file licence.html,
* and also available at http://gate.ac.uk/gate/licence.html).
*/
package gate.util;
import gate.Executable;
import gate.creole.ExecutionException;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class provides methods for making entries in the shared log
* maintained by the GATE system. User should use various methods
* provided by this class and as described in the following example.
*
*
*
* TODO: Provide example here.
*
*
*
* @author niraj
*/
public class Benchmark {
/**
* variable that keeps track of if logging is ON or OFF.
*/
protected static boolean benchmarkingEnabled = false;
/**
* corpus name feature
*/
public final static String CORPUS_NAME_FEATURE = "corpusName";
/**
* application name feature
*/
public final static String APPLICATION_NAME_FEATURE = "applicationName";
/**
* document name feature
*/
public final static String DOCUMENT_NAME_FEATURE = "documentName";
/**
* processing resource name feature
*/
public final static String PR_NAME_FEATURE = "prName";
/**
* message feature
*/
public final static String MESSAGE_FEATURE = "message";
// various check point ids
public final static String PR_PREFIX = "pr_";
public final static String DOCUMENT_LOADED = "documentLoaded";
public final static String DOCUMENT_SAVED = "documentSaved";
public final static String WRITING_FVS_TO_DISK = "writingFVsToDisk";
public final static String ANNOTS_TO_NLP_FEATURES = "annotsToNlpFeatures";
public final static String NLP_FEATURES_TO_FVS = "nlpFeaturesToFVs";
public final static String READING_LEARNING_INFO = "readingLearningInfo";
public final static String MODEL_APPLICATION = "modelApplication";
public final static String WRITING_NGRAM_MODEL = "writingNgramModel";
public final static String TERM_DOC_STATS = "termDocStats";
public final static String FILTERING = "filtering";
public final static String MODEL_TRAINING = "modelTraining";
public final static String EVALUATION = "evaluation";
public final static String NLP_LABELS_TO_DATA_LABELS = "nlpLabelsToDataLabels";
public final static String READING_NLP_FEATURES = "readingNlpFeatures";
public final static String READING_FVS = "readingFVs";
public final static String WEKA_MODEL_TRAINING = "wekaModelTraining";
public final static String PAUM_MODEL_TRAINING = "paumModelTraining";
public final static String READING_CHUNK_LEARNING_DATA = "readingChunkLearningData";
public final static String WEKA_MODEL_APPLICATION = "wekaModelApplication";
public final static String PAUM_MODEL_APPLICATION = "paumModelApplication";
public final static String POST_PROCESSING = "postProcessing";
/**
* Static shared logger used for logging.
*/
public static final Logger logger = LoggerFactory.getLogger(Benchmark.class);
/**
* This returns the current system time.
*/
public static long startPoint() {
return System.currentTimeMillis();
}
/**
* Like {@link #startPoint()} but also logs a message with the
* starting time if benchmarking is enabled. This is intended to be
* used in conjuntion with the three-argument version of checkPoint.
*
* @param benchmarkID the identifier of the process that is just
* starting.
* @return the current time, as logged.
*/
public static long startPoint(String benchmarkID) {
long time = startPoint();
if(benchmarkingEnabled) {
logger.info(time + " START " + benchmarkID);
}
return time;
}
/**
* This method is responsible for making entries into the log.
*
* @param startTime - when did the actual process started. This value
* should be the value obtained by Benchmark.startPoint()
* method invoked at the begining of the process.
* @param benchmarkID - a unique ID of the resource that should be
* logged with this message.
* @param objectInvokingThisCheckPoint - The benchmarkable object that
* invokes this method.
* @param benchmarkingFeatures - any features (key-value pairs) that should be
* reported in the log message. toString() method will be
* invoked on the objects.
*/
public static void checkPoint(long startTime, String benchmarkID,
Object objectInvokingThisCheckPoint, Map