|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgate.util.reporting.DocTimeReporter
public class DocTimeReporter
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. |
private HashSet<String> |
allDocs
An HashSet containing names of the documents matching the given search string. |
private File |
benchmarkFile
A File handle to input benchmark file. |
private LinkedHashMap<String,Object> |
docContainer
A LinkedHashMap containing the documents matching the given PRs. |
private static int |
FILE_CHUNK_SIZE
Chunk size in which file will be read |
private float |
globalTotal
Total time taken by the given pipeline for the current logical run. |
private String |
logicalStart
A marker indicating the start of current logical run. |
static String |
MATCH_ALL_PR_REGEX
The default value for search string matching PRs for given run. |
private HashSet<String> |
matchingPRs
An HashSet containing PR names matching the search string. |
private int |
maxDocumentInReport
No of documents to be displayed against matching PRs. |
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. |
private static String |
NL
An OS independent line separator |
private String |
pipelineName
Name of the given pipeline |
private String |
printMedia
Report media. |
private String |
PRMatchingRegex
Search string, could be a PR name. |
private File |
reportFile
Path where to save the report file. |
private static int |
STATUS_ERROR
Status flag for error exit. |
private static int |
STATUS_NORMAL
Status flag for normal exit. |
private File |
temporaryDirectory
Folder where the benchmark.txt files are created for specific pipeline log entries. |
int |
validEntries
An integer containing the count of total valid log entries present in input file provided. |
| Constructor Summary | |
|---|---|
DocTimeReporter()
No argument constructor. |
|
DocTimeReporter(String[] args)
A constructor to be used while executing the tool from the command line. |
|
| Method Summary | |
|---|---|
Object |
calculate(Object reportContainer)
Calculates the total of the time taken by processing element at each leaf level. |
private void |
deleteFile(File fileToBeDeleted)
A method for deleting a given file. |
private LinkedHashMap<String,Object> |
doTotal(LinkedHashMap<String,Object> reportContainer)
Computes the sub totals at each processing level. |
void |
executeReport()
A single method to execute report (A command line counter part API ). |
private void |
generateReport()
Calls store, calculate and printReport for generating the actual report. |
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()
|
private void |
initTmpDir()
|
private boolean |
isPRMatched(String benchmarkIDs,
String searchString)
Provides the functionality to match a user input string with the PR in the given benchmark ids. |
static void |
main(String[] args)
A main method which acts as a entry point while executing a report via command line |
private void |
organizeEntries(LinkedHashMap<String,Object> store,
String matchedPR,
String bTime,
String docName)
Organizes the valid data extracted from the log entries into LinkedHashMap. |
void |
parseArguments(String[] args)
Parses the report command lime arguments. |
private boolean |
parseLinesFromLast(byte[] bytearray,
Vector<String> lastNlines,
long fromPos)
A method to ensure that the required line is read from the given file part. |
void |
printReport(Object reportSource,
File outputFile)
Prints a report as per the value provided for print media option. |
private void |
printToHTML(LinkedHashMap<String,Object> reportSource,
File outputFile)
Prints the document level statistics report in HTML format. |
private void |
printToText(Object reportContainer,
File outputFile)
Prints benchmark report in text format. |
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. |
private LinkedHashMap |
sortHashMapByValues(LinkedHashMap passedMap)
Sorts LinkedHashMap by its values(natural descending order). keeps the duplicates as it is. |
private void |
splitBenchmarkFile(File benchmarkFile,
File report)
Provides the functionality to separate out pipeline specific benchmark entries in separate temporary benchmark files in a temporary folder in the current working directory. |
Object |
store(File inputFile)
Stores GATE processing elements and the time taken by them in an in-memory data structure for report generation. |
private long |
tail(File fileToBeRead,
int chunkSize)
A method for reading the file upside down. |
static void |
usage()
Display a usage message |
private boolean |
validateLogEntry(String benchmarkIDChain,
ArrayList<String> startTokens)
Ignores the inconsistent log entries from the benchmark file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private File benchmarkFile
private String printMedia
private int maxDocumentInReport
private String PRMatchingRegex
private String logicalStart
private File reportFile
private HashSet<String> allDocs
private HashSet<String> matchingPRs
private float globalTotal
private LinkedHashMap<String,Object> docContainer
private File temporaryDirectory
private String pipelineName
private static final int STATUS_NORMAL
private static final int STATUS_ERROR
private static final int FILE_CHUNK_SIZE
private static final String NL
public int validEntries
public static final String MEDIA_TEXT
public static final String MEDIA_HTML
public static final int ALL_DOCS
public static final String MATCH_ALL_PR_REGEX
| Constructor Detail |
|---|
public DocTimeReporter()
DocTimeReporter(String[] args)
args - array containing command line arguments.| Method Detail |
|---|
private void initTmpDir()
public Object calculate(Object reportContainer)
calculate in interface BenchmarkReportablereportContainer - An Object of type LinkedHashMapprivate LinkedHashMap sortHashMapByValues(LinkedHashMap passedMap)
passedMap - An Object of type LinkedHashMap to be sorted by its values.
private LinkedHashMap<String,Object> doTotal(LinkedHashMap<String,Object> reportContainer)
reportContainer - An Object of type LinkedHashMap
public void printReport(Object reportSource,
File outputFile)
printReport in interface BenchmarkReportablereportSource - An Object of type LinkedHashMapoutputFile - Path where to save the report.
private void printToText(Object reportContainer,
File outputFile)
reportContainer - An Object of type LinkedHashMapoutputFile - An object of type File representing the output report file.
public Object store(File inputFile)
throws BenchmarkReportInputFileFormatException
store in interface BenchmarkReportableinputFile - A handle to the input benchmark file.
BenchmarkReportInputFileFormatException - if the input file provided is not a valid benchmark file.
private void organizeEntries(LinkedHashMap<String,Object> store,
String matchedPR,
String bTime,
String docName)
store - A global LinkedHashMap containing the processing elements (with
time in milliseconds) in hierarchical structure.matchedPR - A PR matching the given search string.bTime - Time taken by the specific processing element.docName - Name of the document being processed.
private void printToHTML(LinkedHashMap<String,Object> reportSource,
File outputFile)
reportSource - An Object of type LinkedHashMapoutputFile - An object of type File representing the output report file to
which the HTML report is to be written.
private boolean validateLogEntry(String benchmarkIDChain,
ArrayList<String> startTokens)
benchmarkIDChain - the chain of benchmark ids. This is the third token in the
benchmark file.startTokens - an array of first tokens in the benchmark id chain.
public void parseArguments(String[] args)
parseArguments in interface BenchmarkReportableargs - array containing the command line arguments.public String getPrintMedia()
public void setPrintMedia(String printMedia)
printMedia - Type of media on which the report will be generated.
Must be MEDIA_TEXT or MEDIA_HTML.
The default is MEDIA_HTML.
private boolean isPRMatched(String benchmarkIDs,
String searchString)
benchmarkIDs - A string of benchmarkIDs containing the PR name at the start of
string.searchString - The string to be matched for PR name.
private void deleteFile(File fileToBeDeleted)
throws BenchmarkReportFileAccessException
fileToBeDeleted - A handle of the file to be deleted.
BenchmarkReportFileAccessException - if a given file could not be deleted.
private void splitBenchmarkFile(File benchmarkFile,
File report)
throws BenchmarkReportFileAccessException,
BenchmarkReportInputFileFormatException
benchmarkFile - An object of type File representing the input benchmark file.report - A file handle to the report file to be written.
BenchmarkReportFileAccessException - if any error occurs while accessing the input benchmark file or
while splitting it.
BenchmarkReportExecutionException - if the given input benchmark file is modified while generating
the report.
BenchmarkReportInputFileFormatException
private long tail(File fileToBeRead,
int chunkSize)
throws BenchmarkReportInputFileFormatException
fileToBeRead - An object of the file to be read.chunkSize - An integer specifying the size of the chunks in which file will be
read.
BenchmarkReportInputFileFormatException
private boolean parseLinesFromLast(byte[] bytearray,
Vector<String> lastNlines,
long fromPos)
bytearray - A part of a file being read upside down.lastNlines - A vector containing the lines extracted from file part.fromPos - A long value indicating the start of a file part.
public static void usage()
public static void main(String[] args)
throws BenchmarkReportInputFileFormatException,
BenchmarkReportFileAccessException
args - A string array containing the command line arguments.
BenchmarkReportExecutionException - if a given input file is modified while generating the report.
BenchmarkReportInputFileFormatException
BenchmarkReportFileAccessException
private void generateReport()
throws BenchmarkReportInputFileFormatException,
BenchmarkReportFileAccessException
BenchmarkReportInputFileFormatException
BenchmarkReportFileAccessException
public void executeReport()
throws BenchmarkReportInputFileFormatException,
BenchmarkReportFileAccessException
BenchmarkReportable
executeReport in interface BenchmarkReportableBenchmarkReportInputFileFormatException
BenchmarkReportFileAccessExceptionpublic String getLogicalStart()
public void setLogicalStart(String logicalStart)
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.public File getBenchmarkFile()
setBenchmarkFile(java.io.File)public void setBenchmarkFile(File benchmarkFile)
benchmarkFile - Input benchmark file.public File getReportFile()
setReportFile(java.io.File)public void setReportFile(File reportFile)
reportFile - file path to the report file to write.public int getMaxDocumentInReport()
public void setMaxDocumentInReport(int maxDocumentInReport)
maxDocumentInReport - Maximum number of documents contained in
the report. Use the constant ALL_DOCS for reporting all documents.
The default is 10.public String getPRMatchingRegex()
public void setPRMatchingRegex(String matchingRegex)
matchingRegex - regular expression to match PR names
present in the benchmark file. The default is MATCH_ALL_PR_REGEX.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||