gate.util.reporting
Class DocTimeReporter

java.lang.Object
  extended by gate.util.reporting.DocTimeReporter
All Implemented Interfaces:
BenchmarkReportable

public class DocTimeReporter
extends Object
implements BenchmarkReportable

A reporter class to generate a report on time taken by each document within given corpus.


Field Summary
static int ALL_DOCS
          This integer constant when set as No of Docs indicates that the report have all the documents matching a given PR.
static String MATCH_ALL_PR_REGEX
          The default value for search string matching PRs for given run.
static String MEDIA_HTML
          This string constant when set as print media indicates that the report is printed in HTML format.
static String MEDIA_TEXT
          This string constant when set as print media indicates that the report is printed in TEXT format.
 int validEntries
          An integer containing the count of total valid log entries present in input file provided.
 
Constructor Summary
DocTimeReporter()
          No argument constructor.
 
Method Summary
 Object calculate(Object reportContainer)
          Calculates the total of the time taken by processing element at each leaf level.
 void executeReport()
          A single method to execute report (A command line counter part API ).
 File getBenchmarkFile()
           
 String getLogicalStart()
          Returns the marker indicating logical start of a run.
 int getMaxDocumentInReport()
          Returns the maximum no of documents to be shown in the report.
 String getPrintMedia()
          Returns the name of the media on which report will be generated. e.g. text, HTML.
 String getPRMatchingRegex()
          Returns the search string to be matched to PR names present in the log entries.
 File getReportFile()
           
static void main(String[] args)
          A main method which acts as a entry point while executing a report via command line
 void parseArguments(String[] args)
          Parses the report command lime arguments.
 void printReport(Object reportSource, File outputFile)
          Prints a report as per the value provided for print media option.
 void setBenchmarkFile(File benchmarkFile)
          Sets the input benchmark file from which the report is generated.
 void setLogicalStart(String logicalStart)
          Sets optionally a string indicating the logical start of a run.
 void setMaxDocumentInReport(int maxDocumentInReport)
          Maximum number of documents contained in the report.
 void setPrintMedia(String printMedia)
          Sets the media on which report will be generated.
 void setPRMatchingRegex(String matchingRegex)
          Search string to match PR names present in the benchmark file.
 void setReportFile(File reportFile)
          If not set, the default is the file name "report.txt/html" in the system temporary directory.
 Object store(File inputFile)
          Stores GATE processing elements and the time taken by them in an in-memory data structure for report generation.
static void usage()
          Display a usage message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validEntries

public int validEntries
An integer containing the count of total valid log entries present in input file provided.


MEDIA_TEXT

public static final String MEDIA_TEXT
This string constant when set as print media indicates that the report is printed in TEXT format.

See Also:
Constant Field Values

MEDIA_HTML

public static final String MEDIA_HTML
This string constant when set as print media indicates that the report is printed in HTML format.

See Also:
Constant Field Values

ALL_DOCS

public static final int ALL_DOCS
This integer constant when set as No of Docs indicates that the report have all the documents matching a given PR.

See Also:
Constant Field Values

MATCH_ALL_PR_REGEX

public static final String MATCH_ALL_PR_REGEX
The default value for search string matching PRs for given run.

See Also:
Constant Field Values
Constructor Detail

DocTimeReporter

public DocTimeReporter()
No argument constructor.

Method Detail

calculate

public Object calculate(Object reportContainer)
Calculates the total of the time taken by processing element at each leaf level. Also calculates the difference between the actual time taken by the resources and system noted time.

Specified by:
calculate in interface BenchmarkReportable
Parameters:
reportContainer - An Object of type LinkedHashMap containing the processing elements (with time in milliseconds) in hierarchical structure.
Returns:
An Object containing modified hierarchical structure of processing elements with totals and All others embedded in it.

printReport

public void printReport(Object reportSource,
                        File outputFile)
Prints a report as per the value provided for print media option.

Specified by:
printReport in interface BenchmarkReportable
Parameters:
reportSource - An Object of type LinkedHashMap containing the processing elements (with time in milliseconds) in hierarchical structure.
outputFile - Path where to save the report.

store

public Object store(File inputFile)
             throws BenchmarkReportInputFileFormatException
Stores GATE processing elements and the time taken by them in an in-memory data structure for report generation.

Specified by:
store in interface BenchmarkReportable
Parameters:
inputFile - A handle to the input benchmark file.
Returns:
An Object of type LinkedHashMap containing the processing elements (with time in milliseconds) in hierarchical structure. Null if there was an error.
Throws:
BenchmarkReportInputFileFormatException - if the input file provided is not a valid benchmark file.

parseArguments

public void parseArguments(String[] args)
Parses the report command lime arguments.

Specified by:
parseArguments in interface BenchmarkReportable
Parameters:
args - array containing the command line arguments.

getPrintMedia

public String getPrintMedia()
Returns the name of the media on which report will be generated. e.g. text, HTML.

Returns:
printMedia A String containing the name of the media on which report will be generated.

setPrintMedia

public void setPrintMedia(String printMedia)
Sets the media on which report will be generated.

Parameters:
printMedia - Type of media on which the report will be generated. Must be MEDIA_TEXT or MEDIA_HTML. The default is MEDIA_HTML.

usage

public static void usage()
Display a usage message


main

public static void main(String[] args)
                 throws BenchmarkReportInputFileFormatException,
                        BenchmarkReportFileAccessException
A main method which acts as a entry point while executing a report via command line

Parameters:
args - A string array containing the command line arguments.
Throws:
BenchmarkReportExecutionException - if a given input file is modified while generating the report.
BenchmarkReportInputFileFormatException
BenchmarkReportFileAccessException

executeReport

public void executeReport()
                   throws BenchmarkReportInputFileFormatException,
                          BenchmarkReportFileAccessException
Description copied from interface: BenchmarkReportable
A single method to execute report (A command line counter part API ). Call this method after setting the report parameters.

Specified by:
executeReport in interface BenchmarkReportable
Throws:
BenchmarkReportInputFileFormatException
BenchmarkReportFileAccessException

getLogicalStart

public String getLogicalStart()
Returns the marker indicating logical start of a run.

Returns:
logicalStart A String containing the marker indicating logical start of a run.

setLogicalStart

public void setLogicalStart(String logicalStart)
Sets optionally a string indicating the logical start of a run.

Parameters:
logicalStart - A String indicating the logical start of a run. Useful when you you have marked different runs in your benchmark file with this string at their start. By default the value is null.

getBenchmarkFile

public File getBenchmarkFile()
Returns:
benchmarkFile path to input benchmark file.
See Also:
setBenchmarkFile(java.io.File)

setBenchmarkFile

public void setBenchmarkFile(File benchmarkFile)
Sets the input benchmark file from which the report is generated. By default use the file named "benchmark.txt" from the application execution directory.

Parameters:
benchmarkFile - Input benchmark file.

getReportFile

public File getReportFile()
Returns:
reportFile file path where the report file is written.
See Also:
setReportFile(java.io.File)

setReportFile

public void setReportFile(File reportFile)
If not set, the default is the file name "report.txt/html" in the system temporary directory.

Parameters:
reportFile - file path to the report file to write.

getMaxDocumentInReport

public int getMaxDocumentInReport()
Returns the maximum no of documents to be shown in the report.

Returns:
maxDocumentInReport An integer specifying the maximum no of documents to be shown in the report.

setMaxDocumentInReport

public void setMaxDocumentInReport(int maxDocumentInReport)
Maximum number of documents contained in the report.

Parameters:
maxDocumentInReport - Maximum number of documents contained in the report. Use the constant ALL_DOCS for reporting all documents. The default is 10.

getPRMatchingRegex

public String getPRMatchingRegex()
Returns the search string to be matched to PR names present in the log entries.

Returns:
PRMatchingRegex A String to be matched to PR names present in the log entries.

setPRMatchingRegex

public void setPRMatchingRegex(String matchingRegex)
Search string to match PR names present in the benchmark file.

Parameters:
matchingRegex - regular expression to match PR names present in the benchmark file. The default is MATCH_ALL_PR_REGEX.