Sorry to have been so long getting this work done. Life gets in the way of computing.
What I have done is expand on the LoadTest macro with full logging support and the ability to change the caching prefs. This new macro called LgLoadTest will log each test to a log file. There is also an option to write the values of a selected group of prefs to the log file. The prefs selected for watching are in a file called Pref_Watch.dat which should be located in the LgLoadTest folder under the user macros folder. That is also the folder where the log file will be created.
The Pref_Watch.dat file has the following structure. Each pref requires one line. That line consists of the pref type followed by a comma followed by a space followed by the pref name. The structure must be exact because the program must parse the type and name into variables in order to work with them. You may add or delete prefs as you desire.
Options to edit the Pref_Watch.dat file, and to toggle the disk and memory caching are also provided. The user can recover from un-matched values for disk and memory caching but no option is provided to induce that state.
If you used a button to execute the LoadTest macro you can direct that or another button to LgLoadTime_RunCode.
This may only work in ASCII. Strings must be parsed in both the kmm and js files. I do not have the knowledge required to do this is UTF8.
LgLoadTime.kmm
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- LgLoadTime.kmm
# ---------- K-Meleon Macro Language to poll the time before and after pageload ---------------
#
# Dependencies : main.kmm
# Resources : LgLoadTime.js, wscript.exe
# Pref_Watch.dat ( ANSI only )
# Preferences : "k-meleon_LgLoadTime_active"
# Version : 1.0 2008-10-26
# --------------------------------------------------------------------------------
## Run the loading tests using LgLoadTime_RunCode
## ----------------------------------------------
LgLoadTime_RunCode {
setpref( BOOL, "k-meleon_LgLoadTime_active", TRUE);
### values on the exec are path, action, Pref values string, and URL
exec("wscript.exe \"".$_LgLoadTime_J_Path."\" 1 null null null");
$_LgLoadTime_URL = $URLBAR ;
open( $_LgLoadTime_URL );
}
## PRIVATE ==============
_LgLoadTime_LogPrefs {
macros( &_LgLoadTime_GrabPrefs ) ;
#setclipboard("wscript.exe \"".$_LgLoadTime_J_Path."\" 3 \"".$_LgLoadTime_P_Export."\" \"".$_LgLoadTime_Path."\" null" ) ;
exec("wscript.exe \"".$_LgLoadTime_J_Path."\" 3 \"".$_LgLoadTime_P_Export."\" \"".$_LgLoadTime_Path."\" null" ) ;
}
_LgLoadTime_GrabPrefs{
$_LgLoadTime_P_Export = "" ;
$_LgLoadTime_P_line = 0 ;
$_LgLoadTime_P_Input = readfile($_LgLoadTime_P_Path) ;
### force a newline character at end of input file
$_LgLoadTime_P_Input = $_LgLoadTime_P_Input . "\n" ;
$_LgLoadTime_P_Item_Mark_divide = index( $_LgLoadTime_P_Input, "\n");
while($_LgLoadTime_P_Item_Mark_divide > 4) &_LgLoadTime_PrefsParse ;
}
_LgLoadTime_PrefsParse {
### substr ( string , starting point, number of chars )
$_LgLoadTime_P_Item = substr( $_LgLoadTime_P_Input, 0, $_LgLoadTime_P_Item_Mark_divide) ;
$_LgLoadTime_P_IMd2 = index($_LgLoadTime_P_Item, ",");
$_LgLoadTime_P_ItemType = substr($_LgLoadTime_P_Item, 0, $_LgLoadTime_P_IMd2);
$_LgLoadTime_P_ItemString= substr($_LgLoadTime_P_Item, $_LgLoadTime_P_IMd2 +2);
$_LgLoadTime_P_Value = getpref($_LgLoadTime_P_ItemType, $_LgLoadTime_P_ItemString);
### $_LgLoadTime_P_Value has the value of the pref
### $_LgLoadTime_P_line has the file position of the pref
### add the current line and value to the export variable
$_LgLoadTime_P_Export = $_LgLoadTime_P_Export . $_LgLoadTime_P_Value . "|" ;
### strip the current pref from the input string
$_LgLoadTime_P_Input = substr($_LgLoadTime_P_Input, $_LgLoadTime_P_Item_Mark_divide + 1) ;
#alert($_LgLoadTime_P_Input, "remaining input") ;
$_LgLoadTime_P_Item_Mark_divide = index( $_LgLoadTime_P_Input, "\n");
$_LgLoadTime_P_line = $_LgLoadTime_P_line +1 ;
}
_LgLoadTime_Loaded_Run {
getpref( BOOL, "k-meleon_LgLoadTime_active" )== true ? &_LgLoadTime_Loaded_RunTrue : 0;
}
_LgLoadTime_Loaded_RunTrue {
### values on the exec are path, action, Pref values string, and URL
exec("wscript.exe \"".$_LgLoadTime_J_Path."\" 2 null \"".$_LgLoadTime_Path."\" \"".$_LgLoadTime_URL."\"") ;
setclipboard("wscript.exe \"".$_LgLoadTime_J_Path."\" 2 null \"".$_LgLoadTime_Path."\" \"".$_LgLoadTime_URL."\"") ;
togglepref( BOOL, "k-meleon_LgLoadTime_active") ;
}
## Run notepad.exe on the pref_watch file
## --------------------------------------
_LgLoadTime_EditPrefs{
exec("notepad.exe \"".$_LgLoadTime_P_Path."\"") ;
}
## Run notepad.exe on the LgLoadTime.log file
## --------------------------------------
_LgLoadTime_ViewLog{
exec("notepad.exe \"".$_LgLoadTime_Log_Path."\"") ;
}
_LgLoadTime_Tog_Cache{
$_LgLoadTime_MCache = getpref(BOOL, "browser.cache.memory.enable") ;
$_LgLoadTime_DCache = getpref(BOOL, "browser.cache.disk.enable") ;
## Obtain match value prior to changing 1&0 to true&false
$_LgLoadTime_Cache_Match = $_LgLoadTime_MCache + $_LgLoadTime_DCache ;
$_LgLoadTime_MCache == 1 ? $_LgLoadTime_MCache= "True" : $_LgLoadTime_MCache= "False" ;
$_LgLoadTime_DCache == 1 ? $_LgLoadTime_DCache= "True" : $_LgLoadTime_DCache= "False" ;
$_LgLoadTime_Cache_Match == 1 ? &_LgLoadTime_TogNM_Cache : &_LgLoadTime_TogIsM_Cache ;
}
_LgLoadTime_TogNM_Cache {
$_LgLoadTime_TogNM_Confirm1 = confirm("Disk caching = " . $_LgLoadTime_DCache, "Toggle this pref ?", YESNO, QUESTION) ;
$_LgLoadTime_TogNM_Confirm1 == "YES" ? togglepref( BOOL, "browser.cache.disk.enable") : 0 ;
$_LgLoadTime_TogNM_Confirm2 = confirm("Memory caching = " . $_LgLoadTime_MCache, "Toggle this pref ?", YESNO, QUESTION) ;
$_LgLoadTime_TogNM_Confirm2 == "YES" ? togglepref( BOOL, "browser.cache.memory.enable") : 0 ;
}
_LgLoadTime_TogIsM_Cache {
$_LgLoadTime_TogIsM_Confirm = confirm("Disk & Memory = " . $_LgLoadTime_DCache, "Toggle these prefs ?", YESNO, QUESTION) ;
$_LgLoadTime_TogIsM_Confirm == "YES" ? &_LgLoadTime_TogBoth : 0 ;
}
_LgLoadTime_TogBoth {
togglepref( BOOL, "browser.cache.memory.enable") ;
togglepref( BOOL, "browser.cache.disk.enable") ;
}
_LgLoadTime_BuildMenu{
# add another option to Misc section of Tools menu
$_LgLoadTime_Popm = "LgLoadTime Test" ;
setmenu("&Tools",popup,$_LgLoadTime_Popm,Misc);
setmenu($_LgLoadTime_Popm,macro,_("Run Loading Test"),LgLoadTime_RunCode,0);
setmenu($_LgLoadTime_Popm,macro,_("Edit Watch Prefs"),_LgLoadTime_EditPrefs,1);
setmenu($_LgLoadTime_Popm,macro,_("Log Pref Values"),_LgLoadTime_LogPrefs,2);
setmenu($_LgLoadTime_Popm,macro,_("View Log File"),_LgLoadTime_ViewLog,3);
setmenu($_LgLoadTime_Popm,macro,_("Toggle Caching"),_LgLoadTime_Tog_Cache,4);
}
_LgLoadTime_GetPath{
$__Data=readfile(getfolder(MacroFolder)."\\LgLoadTime.kmm");
$_LgLoadTime_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder);
$_LgLoadTime_J_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\LgLoadTime.js";
$_LgLoadTime_P_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\LgLoadTime\\Pref_Watch.dat";
$_LgLoadTime_Log_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\LgLoadTime\\LgLoadTime.log";
}
$OnLoad=$OnLoad."_LgLoadTime_Loaded_Run;";
$OnStartup=$OnStartup."_LgLoadTime_GetPath;";
$OnInit=$OnInit."_LgLoadTime_BuildMenu;";
$macroModules=$macroModules."LgLoadTime;";
LgLoadTime.js
/* LgLoadTimejs by JamesD, version 1.0 2008-10-26
This script is a helper application for the K-Meleon Macro Module BRLoadTime.kmm that
produces an elasped time for a page load for a list of sites times a fixed number of runs.
Windows Script Host 2.0 (or better) required!
WSH is part of Microsoft Internet Explorer 5.0 and newer. Latest version of WSH is
available at http://msdn.microsoft.com/scripting/
*/
// Arguments are action code, Pref Values string, Path, URL
if(WScript.Arguments.count()==4)
{
// start of a loading test
if (WScript.Arguments(0) == 1){
var d, t ;
d = new Date();
t = d.getTime();
var WshShell = new ActiveXObject("WScript.Shell") ;
WshShell.RegWrite ("HKCU\\Software\\KMELEON\\BRLoadTime\\start", t, "REG_SZ");
}
// finish of a loading test - write to log
if (WScript.Arguments(0) == 2){
var d, t ;
var spacer6 = " " ;
d = new Date();
t = d.getTime();
var WshShell = new ActiveXObject("WScript.Shell") ;
WshShell.RegWrite ("HKCU\\Software\\KMELEON\\BRLoadTime\\finish", t, "REG_SZ");
var $_BRLoadTime_Start = WshShell.RegRead ("HKCU\\Software\\KMELEON\\BRLoadTime\\start") ;
var $_BRLoadTime_Finish = WshShell.RegRead ("HKCU\\Software\\KMELEON\\BRLoadTime\\finish") ;
var $_BRLoadTime_Elapsed = $_BRLoadTime_Finish - $_BRLoadTime_Start ;
var $_BRLoadTime_Seconds = $_BRLoadTime_Elapsed / 1000 ;
var objfso2 = new ActiveXObject("Scripting.FileSystemObject");
WScript.Echo( $_BRLoadTime_Seconds + " Seconds elapsed time") ;
WshShell.RegDelete ("HKCU\\Software\\KMELEON\\BRLoadTime\\start") ;
WshShell.RegDelete ("HKCU\\Software\\KMELEON\\BRLoadTime\\finish") ;
var TestURL = (WScript.Arguments(3)) ;
var ForReading = 1, ForWriting = 2, ForAppending = 8;
// open the log file for appending true means create if not exist
var Test_Log_2 = WScript.Arguments(2)+"\\LgLoadTime\\LgLoadTime.log";
var log2 = objfso2.OpenTextFile(Test_Log_2, ForAppending, true);
// write to the log file the datetime, the URL, and the elasped time
log2.writeline(spacer6);
log2.writeline(d+spacer6+$_BRLoadTime_Seconds+" Seconds elapsed time");
log2.writeline("URL = " + TestURL);
log2.Close();
} // end of =2 loop
// write the preference list with current values to log
if (WScript.Arguments(0) == 3) {
var d3, PV, PN, i, spacecnt ;
var spacer6 = " ", spaces = " - - - - - - -" ;
var Prefs, log3, k, words3, look3 ;
var ForReading = 1, ForWriting = 2, ForAppending = 8;
var Pref_List = new Array();
var Pref_Name = new Array();
var Pref_Width = new Array();
var Pref_Type = new Array();
var Pref_Vals = (WScript.Arguments(1)) ;
var objfso3 = new ActiveXObject("Scripting.FileSystemObject");
var Test_Log_3 = WScript.Arguments(2)+"\\LgLoadTime\\LgLoadTime.log";
var Pref_Watch_file = WScript.Arguments(2)+"\\LgLoadTime\\Pref_Watch.dat";
d3 = new Date();
// read augument 2 into an array of Preference values
look3 = Pref_Vals.indexOf("|");
k = 0 ;
while ( look3 > 0) {
Pref_List[k] = Pref_Vals.substr(0,look3);
Pref_Width[k] = look3 ;
Pref_Vals = Pref_Vals.substr(look3 +1);
look3 = Pref_Vals.indexOf("|");
k= k + 1 ;
} // end reading current pref values
PV = Pref_List.length ;
// check for existance of Pref_watch file
if (objfso3.FileExists(Pref_Watch_file)) {
Prefs = objfso3.OpenTextFile(Pref_Watch_file, ForReading );
k = 0 ; // set the index counter for the array to zero
while ( !Prefs.AtEndOfStream ) {
// read one line from the file
words = Prefs.ReadLine();
// find the "comma" in the line
look3 = words.indexOf(",");
Pref_Type[k] = words.substr(0, look3);
Pref_Name[k] = words.substr(look3 +2) ;
k = k+1 ;
} // end of while loop
Prefs.Close() ;
PN = Pref_Name.length ;
// Pref_List array has the values for the prefs
// Pref_Name array has the names of the prefs
if (PV == PN) {
// open the log file for appending
log3 = objfso3.OpenTextFile(Test_Log_3, ForAppending, true);
log3.writeline(spacer6);
log3.writeline(d3 + " Preferences") ;
log3.writeline(spacer6);
log3.writeline("Preference Value" + spacer6 + "Preference Name");
for (i=0; i < Pref_List.length ; ++i ) {
// adjust "BOOL" types for true or false instead of 0 and 1
if (Pref_Type == "BOOL" ) {
if (Pref_List == 1) {
Pref_List = "True" ;
Pref_Width = 4 ;
}
if (Pref_List == 0) {
Pref_List = "False" ;
Pref_Width = 5 ;
}
}
// calculate the space between value and name
spacecnt = spaces.substr(0, 13-Pref_Width);
// write the line to the log
log3.writeline(spacer6+Pref_List + spacecnt + " " + Pref_Name) ;
}
log3.Close();
WScript.echo("Log written.");
} else {
WScript.echo("Number mismatch between name list and value list");
}
} else {
WScript.echo("Pref_Watch.dat -- File Not Found.");
}
} // closes the while loop
}
else
{
objArgs = WScript.Arguments ;
WScript.Echo(WScript.Arguments.Count());
for (i=0; i<objArgs.length; i++)
{
WScript.Echo(objArgs(i))
}
}
Pref_Watch.dat This file in LgLoadTime folder
BOOL, browser.cache.memory.enable
BOOL, browser.cache.disk.enable
INT, content.notify.backoffcount
INT, content.notify.interval
BOOL, content.notify.ontimer
INT, content.notify.threshold
STRING, image.animation_mode