|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.array.VectorWrapper | +--xbn.array.VWObject | +--jsutil.compress.VWJSCStatistics
The statistics for multiple compression processes, with ways to automatically gather and display them. A VWObject
for JSCStatistics
.
Source code: VWJSCStatistics.java
Here is a valid example for a single JavaScript file:
validate_form max validate_form_c 139287 js_uncompressed/ js_maxc/ compression_vfmax.log validate_form max 1 63662 MLCs_Xd Eliminated multilple-line comments. validate_form max 2 62626 elim_XCSTDs Eliminated my personal sanity checks. validate_form max 3 47429 elim_XCMAXs Eliminated error checking. validate_form max 4 34645 SLCs_Xd Eliminated single-line comments. validate_form max 5 32427 SPC_X_SPC Eliminated unneeded spaces. validate_form max 6 28022 TRIM_AND_NLNL Trimmed all lines of tabs and spaces, and eliminated empty lines. validate_form max 7 25873 NL_X_NL Eliminated unneeded line breaks. validate_form max 8 19905 IDENTS_RPLCd Non-public identifiers replaced with two-letter replacements. |
Line one for each JavaScript file in the tddf has this format, each separated by a tab:
.js
' postfixLine two (and all subsequent) for each JavaScript file in the tddf has this format, each separated by a tab:
Each JavaScript file may exist only once, for each possible level of compression. Specifically, each line's first three items must be unique for the entire file.
A single JavaScript file's statistics must be ordered by step ('ORIG', then 1 then 2 ...) and all its lines must exist before the statistic lines for another file's. For example:
validate_form max validate_form 158603 js_uncompressed\ js_maxc\ compression_vfmax.log validate_form max 1 ELIM_MLCS 73949 Eliminated all comments. validate_form max 2 ELIM_XCSTDs 72913 Eliminated my personal sanity checks. validate_form max 3 ELIM_XCMAXs 57409 Eliminated error checking. validate_form max 4 SPC_X_SPC 40099 Eliminated unneeded spaces. validate_form max 5 NL_X_NL 32666 Eliminated unneeded line breaks. validate_form max 6 IDENTS_RPLCD 26682 Replaced all identifiers with one/two character tokens. vf_dbgVF stdmax vf_dbgVF 4085 js_uncompressed\ js_stdc\ compression_dbg.log vf_dbgVF stdmax 1 ELIM_COMMENTS 2190 Eliminated all comments. vf_dbgVF stdmax 2 SPC_X_SPC 2032 Eliminated unneeded spaces. vf_dbgVF stdmax 3 NL_X_NL 1747 Eliminated unneeded line breaks. vf_dbgVF stdmax 4 IDENTS_RPLCD 1295 Eliminated unneeded line breaks. vf_stASIF max vf_stASIF 5545 js_uncompressed\ js_maxc\ compression_stasifmax.log vf_stASIF max 1 ELIM_MLCs 3833 Eliminated multi-line comments. vf_stASIF max 2 ELIM_XCMAXs 2290 Eliminated error checking. vf_stASIF max 3 ELIM_SLCs 979 Eliminated single-line comments. vf_stASIF max 4 SPC_X_SPC 926 Eliminated unneeded spaces. vf_stASIF max 5 NL_X_NL 678 Eliminated unneeded line breaks. vf_stASIF max 6 IDENTS_RPLCD 490 Replaced all identifiers with one/two character tokens. |
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
VWJSCStatistics()
Create a VWJSCStatistics. |
|
VWJSCStatistics(ForLineRetrieval flr_tabDelimData)
Create a VWJSCStatistics. |
|
VWJSCStatistics(Vector v_ector)
Create a VWJSCStatistics. |
Method Summary | |
void |
addJSCStatistics(JSCStatistics jsc_statistics)
Add a JSCStatistics. |
void |
addJSCXtraInfo(sb_sb_c[] asbsbc_configVars,
String s_defaultCLevel)
Add the JSCXtraInfo to each existing JSCStatistics . |
void |
addJSCXtraInfo(sb_sb_c[] asbsbc_configVars,
String s_defaultCLevel,
Outputter optr_dbg)
Add the JSCXtraInfo to each existing JSCStatistics . |
boolean |
doesJSCSExist(String s_jsNoPostUncmprsd,
String s_cLevel)
Does the given name-plus-clevel represent an existing JSCStatistics ?. |
int |
getIdxOfJSCS(String s_jsNoPostUncmprsd,
String s_cLevel)
Get the array index of the JSCStatistics having the provided name. |
JSCStatistics |
getJSCStatistics(int i_dx)
Get the JSCStatistics at an index. |
JSCStatistics |
getJSCStatistics(String s_jsNoPostUncmprsd,
String s_cLevel)
Get the JSCStatistics having the provided name and compression level. |
int |
getJSCStatsIdx(String s_jsNoPostUncmprsd,
String s_cLevel)
Get the array index at which the desired JSCStatistics exists. |
static void |
main(String[] as_cmdLineParams)
Command-line interface for writeStatDocs() . |
void |
writeStatDocs(ForLineRetrieval flr_mainTemplate,
ForLineRetrieval flr_tocRow,
ForLineRetrieval flr_bodySection,
ForLineRetrieval flr_cStepRow,
String s_rUrlToBldBase,
String s_rUrlLogDir,
String s_rUrlStepDir,
int i_chopDec,
OWriter ow_output)
Write html documentation representing the statistics currently represented by the JSCStatistics held by this VWJSCStatistics . |
void |
writeStatDocs(ForLineRetrieval flr_mainTemplate,
ForLineRetrieval flr_tocRow,
ForLineRetrieval flr_bodySection,
ForLineRetrieval flr_cStepRow,
String s_rUrlToBldBase,
String s_rUrlLogDir,
String s_rUrlStepDir,
int i_chopDec,
OWriter ow_output,
Outputter optr_dbg)
Write html documentation representing the statistics currently represented by the JSCStatistics held by this VWJSCStatistics . |
Methods inherited from class xbn.array.VWObject |
add, addAPObject, addArray, clone, getAOObject, getObject, getString, getVWIClone, isNull |
Methods inherited from class xbn.array.VectorWrapper |
doAddInOrder, elementAt, getList, getOrderDirAscDesc, getVector, initializeVector, size |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public VWJSCStatistics()
Create a VWJSCStatistics.
First line calls VWObject()
public VWJSCStatistics(ForLineRetrieval flr_tabDelimData)
Create a VWJSCStatistics.
This first calls VWObject()
flr_tabDelimData
- Represents the text of the tab-delimited data file. Must represent an existing, readable, populated and properly formatted JSCStatistics
tab-delimited data file.public VWJSCStatistics(Vector v_ector)
Create a VWJSCStatistics.
Equal to VWObject(v_ector)
Method Detail |
public final JSCStatistics getJSCStatistics(int i_dx)
Get the JSCStatistics at an index.
(JSCStatistics)[VWObject].getObject(i_dx)
public final void addJSCStatistics(JSCStatistics jsc_statistics)
public final int getJSCStatsIdx(String s_jsNoPostUncmprsd, String s_cLevel)
Get the array index at which the desired JSCStatistics
exists.
s_jsNoPostUncmprsd
- The name of the JavaScript file (minus the '.js' postfix) before it was compressed. See JSCStatistics.getJSNoPostUncmprsd
.s_cLevel
- The compression level for the JavaScript file.JSCStatistics
, having this s_jsNoPostUncmprsd
and s_cLevel
, exists.
-1
If no existing JSCStatistics
has the provided s_jsNoPostUncmprsd
and s_cLevel
.public final void addJSCXtraInfo(sb_sb_c[] asbsbc_configVars, String s_defaultCLevel)
Add the JSCXtraInfo
to each existing JSCStatistics
.
Equal to addJSCXtraInfo(asbsbc_configVars, s_defaultCLevel, (new Outputter()))
public final void addJSCXtraInfo(sb_sb_c[] asbsbc_configVars, String s_defaultCLevel, Outputter optr_dbg)
Add the JSCXtraInfo
to each existing JSCStatistics
. See JSCStatistics.setJSCXtraInfo
.
JSCXtraInfo
configuration textThere are three sets of variables in the configuration text, one for each JSCXtraInfo
constructor parameter:
dl1_[js_file_name]_[clevel]
: s_descLine1
dr_[js_file_name]_[clevel]
s_descTheRest
wd_[js_file_name]_[clevel]
s_whenDwnldd
Rules:
[js_file_name]
: The JavaScript file name, without '.js'. Specifically, this must match the uncompressed file name within an existing JSCStatistics
.[clevel]
: The compression-level within an existing JSCStatistics
. This is required, except for the default c-level, defined below by s_defaultCLevel
, which is forbidden (and assumed to be s_defaultCLevel
).dl1_
variables must be first, and their order determines the ordering of the final output.[js_file_name]_[clevel]
' must equal the name of an existing JSCStatistics
.JSCStatistics
, there must be exactly one of each of the above three config-variables. Extras are not allowed.This is the same tab-delimited data file as exists under 'Ordering' in the tddf format documentation section:
validate_form max validate_form 158603 js_uncompressed/ js_maxc/ compression_vfmax.log validate_form max 1 ELIM_MLCS 73949 Eliminated all comments. validate_form max 2 ELIM_XCSTDs 72913 Eliminated my personal sanity checks. validate_form max 3 ELIM_XCMAXs 57409 Eliminated error checking. validate_form max 4 SPC_X_SPC 40099 Eliminated unneeded spaces. validate_form max 5 NL_X_NL 32666 Eliminated unneeded line breaks. validate_form max 6 IDENTS_RPLCD 26682 Replaced all identifiers with one/two character tokens. vf_dbgVF stdmax vf_dbgVF 4085 js_uncompressed/ js_stdc/ compression_dbg.log vf_dbgVF stdmax 1 ELIM_COMMENTS 2190 Eliminated all comments. vf_dbgVF stdmax 2 SPC_X_SPC 2032 Eliminated unneeded spaces. vf_dbgVF stdmax 3 NL_X_NL 1747 Eliminated unneeded line breaks. vf_dbgVF stdmax 4 IDENTS_RPLCD 1295 Eliminated unneeded line breaks. vf_stASIF max vf_stASIF 5545 js_uncompressed/ js_maxc/ compression_stasifmax.log vf_stASIF max 1 ELIM_MLCs 3833 Eliminated multi-line comments. vf_stASIF max 2 ELIM_XCMAXs 2290 Eliminated error checking. vf_stASIF max 3 ELIM_SLCs 979 Eliminated single-line comments. vf_stASIF max 4 SPC_X_SPC 926 Eliminated unneeded spaces. vf_stASIF max 5 NL_X_NL 678 Eliminated unneeded line breaks. vf_stASIF max 6 IDENTS_RPLCD 490 Replaced all identifiers with one/two character tokens. |
¶¶¶ Section: The description, line one
|
Assume the tddf is in
"C:\vwjscs_test\tddf.txt"
and the compression configuration text is in
"C:\vwjscs_test\cconfig.txt"
import xbn.array.VWObject;
|
[c:\vwjscs_test]java VWJSCSTest
|
addJSCXtraInfo()
: Parameter documentationasbsbc_configVars
- The config-variables, as returned by ConfigReader.getVWObject
, or created by you. Must conform to the above restrictions, and no name (sb_sb_c[idx].sb1
) or value (sb_sb_c[idx].sb2
) may be null.s_defaultCLevel
- The default compression-level. When non-null, this c-level must equal the c-level of an actually-existing JSCStatistics
. When non-null, it is assumed, when no [_clevel]
postfix exists in the config-variable name, that this is the c-level for it. When null, every config-variable name must have a [_clevel]
postfix.optr_dbg
- The Outputter to use for debugging output. May not be null.public final JSCStatistics getJSCStatistics(String s_jsNoPostUncmprsd, String s_cLevel)
Get the JSCStatistics
having the provided name and compression level.
s_jsNoPostUncmprsd
- The name of the JavaScript file (minus the '.js' postfix) before it was compressed. See JSCStatistics.getJSNoPostUncmprsd
.s_cLevel
- The compression level for the JavaScript file.AssertException
- If no existing JSCStatistics
has the provided s_jsNoPostUncmprsd
and s_cLevel
.public final boolean doesJSCSExist(String s_jsNoPostUncmprsd, String s_cLevel)
Does the given name-plus-clevel represent an existing JSCStatistics
?.
(getIdxOfJSCS(s_jsNoPostUncmprsd, s_cLevel) != -1)
public final int getIdxOfJSCS(String s_jsNoPostUncmprsd, String s_cLevel)
Get the array index of the JSCStatistics
having the provided name.
JSCStatistics
where isNameEqual(s_jsNoPostUncmprsd, s_cLevel)
equals true.
-1
if no existing JSCStatistics
has this name.public void writeStatDocs(ForLineRetrieval flr_mainTemplate, ForLineRetrieval flr_tocRow, ForLineRetrieval flr_bodySection, ForLineRetrieval flr_cStepRow, String s_rUrlToBldBase, String s_rUrlLogDir, String s_rUrlStepDir, int i_chopDec, OWriter ow_output)
Write html documentation representing the statistics currently represented by the JSCStatistics
held by this VWJSCStatistics
.
Equal to writeStatDocs(flr_mainTemplate, flr_tocRow, flr_bodySection, flr_cStepRow, s_rUrlToBldBase, s_rUrlLogDir, s_rUrlLogDir, ow_output, (new Outputter()))
public void writeStatDocs(ForLineRetrieval flr_mainTemplate, ForLineRetrieval flr_tocRow, ForLineRetrieval flr_bodySection, ForLineRetrieval flr_cStepRow, String s_rUrlToBldBase, String s_rUrlLogDir, String s_rUrlStepDir, int i_chopDec, OWriter ow_output, Outputter optr_dbg)
Write html documentation representing the statistics currently represented by the JSCStatistics
held by this VWJSCStatistics
.
JSCStatistics jscs = getJSCStatistics([idx]);
JSCXtraInfo jscxi = jscs.getJSCXtraInfo();
int iIdxLastJSCS = (getVector().size() - 1);
flr_*
(Template) parameters~G~
and ~EG~
. For example:
~G~total_bytes_original~EG~
~
') literally, use '\~
'.jscs.getByteSizePrctg*()
) is sent through a Double, translated to a string, and then chopped to i_chopDec
characters. For example:
[PadChopString].get(new Double(jscs.getByteSizeImprv(j, (j - 1))).toString())
flr_mainTemplate
- Points to the source text for the 'main' Template. May not be null, and must contain the following unique gaps:
Gap | Filled with | Notes |
rurl_build_base |
s_rUrlToBldBase . |
Must be the first unique gap. For linking to other things within your project, without having to manually change the link when the output file is moved. |
all_toc_items |
Filled with multiple-and-appended results of the flr_tocRow Template. |
Must be singular, and must be the second unique gap in the file. |
total_bytes_original |
The total bytes of every JavaScript file, before compression. | |
total_bytes_compressed |
The total bytes of every JavaScript file, after compression. | |
avg_bytes_original |
The average bytes of every JavaScript file, before compression. | |
avg_bytes_compressed |
The average bytes of every JavaScript file, after compression. | |
avg_prctg_of_orig |
(avg_bytes_original / avg_bytes_compressed) * 100 |
|
average_improvement |
(100 - avg_prctg_of_orig) |
|
all_body_items |
Filled with multiple-and-appended results of the flr_bodySection Template. |
Must be singular, and must be the last unique gap in the file. |
flr_tocRow
- Points to the source text for the Template representing every table of contents row. This Template is duplicated and appended together, all of which is filled into the flr_mainTemplate
-s all_toc_items
gap. May not be null, and must contain the following unique gaps:
Gap | Filled with | Notes |
rurl_dir_bld_to_cmprsd |
jscs.getRUrlDirBld2Cmprsd() |
|
js_no_post_cmprsd |
jscs.getJSNoPostCmprsd() |
|
compression_level |
jscs.getCLevel() |
|
when_downloaded |
jscxi.getWhenDwnldd() |
|
original_bytes |
jscs.getJSCStep(0).getByteSize() |
|
compressed_bytes |
jscs.getJSCStep(iIdxLastJSCS).getByteSize() |
|
percentage_improved |
jscs.getByteSizePrctgImprv(iIdxLastJSCS, 0) |
|
percentage_of_original |
jscs.getByteSizePrctgOf(iIdxLastJSCS, 0) |
|
jsc_summary |
jscxi.getDescLine1() |
flr_bodySection
- Points to the source text for the Template representing the main section for each compression process. This Template is duplicated and appended together, all of which is filled into the flr_mainTemplate
-s all_body_items
gap. May not be null, and must contain the following unique gaps:
Gap | Filled with | Notes |
rurl_build_base |
s_rUrlToBldBase . |
For linking to other things within your project, without having to manually change the link when the output file is moved. |
rurl_dir_bld_to_cmprsd |
jscs.getRUrlDirBld2Cmprsd() |
|
js_no_post_cmprsd |
jscs.getJSNoPostCmprsd() |
|
compression_level |
jscs.getCLevel() |
|
rurl_dir_bld_to_uncmprsd |
jscs.getRUrlDirBld2Uncmprsd() |
|
js_no_post_uncmprsd |
jscs.getJSNoPostUncmprsd() |
|
log_url |
s_rUrlLogDir + jscs.getCLog() |
|
when_downloaded |
jscxi.getWhenDwnldd() |
|
original_bytes |
jscs.getJSCStep(0).getByteSize() |
|
jsc_desc_line_one |
jscxi.getDescLine1() |
|
jsc_desc_the_rest |
jscxi.getDescTheRest() |
|
all_step_rows |
Filled with multiple-and-appended results of the flr_cStepRow Template. |
Must be singular, and must be the last unique gap in the file. |
flr_cStepRow
- Points to the source text for the Template representing every step (except the original) in the compression process. This Template is duplicated and appended together, all of which is filled into the flr_bodySection
Template's all_step_rows
gap. May not be null, and must contain the following unique gaps:
Gap | Filled with | Notes |
step_source_url |
For rows (and step indexes) 1 through the second-to-last:
s_rUrlStepDir + "zc_" + jscs.getJSNoPostCmprsd() + "_" + jscs.getCLevel() + "_" + idx + "_" + jscs.getJSCStep(idx).getName() + ".js"
For the final step: s_rUrlToBldBase + jscs.getRUrlDirBld2Cmprsd() + jscs.getJSNoPostCmprsd() + ".js" |
|
index |
1..(jscs.getVector().size() - 1) |
|
byte_count |
jscs.getJSCStep(idx).getByteSize() |
|
bytes_since_orig |
jscs.getByteSizeImprv(idx, 0) |
|
bytes_prctg_of_orig |
jscs.getByteSizePrctgOf(idx, 0) |
|
bytes_prctg_imprv_over_orig |
jscs.getByteSizePrctgImprv(idx, 0) |
|
bytes_since_prev |
jscs.getByteSizePrctgImprv(idx, (idx - 1)) |
|
bytes_prctg_of_prev |
jscs.getByteSizePrctgOf(idx, (idx - 1)) |
|
bytes_prctg_imprv_over_prev |
jscs.getByteSizePrctgImprv(idx, (idx - 1)) |
|
description |
jscs.getJSCStep(idx).getDescHtml() |
s_rUrlToBldBase
- The relative link to the build base directory. Used to partially fill all gaps in which jscs.getRUrlDirBld2Uncmprsd
or jscs.getRUrlDirBld2Cmprsd
is used. May not be null or zero characters in length, and must end with a url slash ('/').s_rUrlLogDir
- The relative link to the compression-log directory, in which the overall compression logs exist. Used to partially fill the gap named step_source_url
, in the flr_cStepRow
Template. May not be null or zero characters in length, and must end with a url slash ('/').s_rUrlStepDir
- The relative link to the compression-step directory, in which the overall compression logs exist. Used to partially fill the gap named log_url
, in the flr_bodySection
Template. May not be null or zero characters in length, and must end with a url slash ('/').i_chopDec
- As in JSCStatistics.getReport
, this is the chop number for decimals/percentages. Same restrictions as in getReport
. This function only chops, where getReport
, because it is text only, also pads.optr_output
- The OWriter for this function's final output. May not be null. For example,
new OWFile("C:\\my_web_pages\\compression.html", false)
optr_dbg
- The Outputter to use for debugging output. May not be null.AssertException
- If getVector().size()
equals zero, or addJSCXtraInfo
was not called.public static final void main(String[] as_cmdLineParams)
Command-line interface for writeStatDocs()
. See writeStatDocs()
What | Rqd | Provided to... | ...as | How cmd-line value is translated to function parameter | |
tddf |
File path to the tab-delimited data file | X | constructor |
flr_tabDelimData |
new VWJSCStatistics(new FLRFile(value)) |
ccfg |
File path to the compression configuration file. | X | addJSCXtraInfo |
asbsbc_configVars |
Uses the example code, including comment and variable delimiters, as documented in addJSCXtraInfo |
dfltclvl |
The default compression level. | addJSCXtraInfo |
s_defaultCLevel |
When provided:
[As provided]
When not provided: null |
|
tmplmain |
File path for main Template | X | writeStatDocs |
flr_mainTemplate |
new FLRFile(value) |
tmpltoc |
File path for table-of-contents-row Template | X | writeStatDocs |
flr_tocRow |
new FLRFile(value) |
tmplbody |
File path for body-section Template | X | writeStatDocs |
flr_bodySection |
new FLRFile(value) |
tmplstep |
File path for body-compression-step Template | X | writeStatDocs |
flr_cStepRow |
new FLRFile(value) |
bldbase |
The relative url to the build base. | X | writeStatDocs |
s_rUrlToBldBase |
[As provided] |
rurllogdir |
The relative url from s_rUrlToBldBase to the compression-log directory. |
X | writeStatDocs |
s_rUrlLogDir |
[As provided] |
rurlstepdir |
The relative url from s_rUrlToBldBase to the step-log directory. |
writeStatDocs |
s_rUrlStepDir |
When provided:
[As provided]
When not provided: set to equal s_rUrlLogDir |
|
chopdec |
The chop-length for decimal numbers/percentages. | X | writeStatDocs |
i_chopDec |
[As provided] |
destfile |
The full path and name of the final destination html file. | X | writeStatDocs |
ow_output |
new OWFile(value, false) |
dbg |
Should debugging be written to screen? | writeStatDocs |
optr_dbg |
When provided
new OSysDotOut()
When not provided: new Outputter() |
Assumes the same example data as documented in writeStatDocs()
.
Assume these Templates exist in C:\vwjscs_test\
):
tmplmain: compression.html
tmpltoc: toc_item.tmpl
tmplbody: body.tmpl
tmplstep: body_step_row.tmpl
Call this:
java jsutil.compress.VWJSCStatistics -tddf C:\vwjscs_test\tddf.txt -ccfg C:\vwjscs_test\cconfig.txt -dfltclvl stdmax -tmplmain C:\vwjscs_test\compression.html -tmpltoc C:\vwjscs_test\toc_item.tmpl -tmplbody C:\vwjscs_test\body.tmpl -tmplstep C:\vwjscs_test\body_step_row.tmpl -bldbase ../ -rurllogdir log/ -rurlstepdir documentation/log/ -chopdec 8 -destfile C:\vwjscs_test\output\compression.html -dbg > C:\vwjscs_test\output\stat_docs.log
Here's the resulting output and log. Realistic output can be seen in the validate_form.js
project.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2003-2005, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/jsutiljava