K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmLoadTime

Submitted by: JamesD



Notes:

This macro obtains and displays the time it takes for a page to load. It loads the URL currently in the URL bar. It can be called with quick keys ALT + l . It is most useful if caching is not enabled during the test.




Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):

LoadTime.kmm

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- LoadTime.kmm
# ---------- K-Meleon Macro Language to poll the time before and after pageload ---------------
#
# Dependencies : main.kmm
# Resources    : LoadTime.js
# Preferences  : -
# Version      : 0.7 2008-11-05
# --------------------------------------------------------------------------------

LoadTime_RunCode {
setpref( BOOL, "k-meleon_loadtime_active", TRUE);
$_LoadTime_URL = $URLBAR ;
exec("wscript.exe \"".$_LoadTime_Path."\" 1");
open( $_LoadTime_URL );
}

_LoadTime_Loaded_Run {
getpref( BOOL, "k-meleon_loadtime_active" )== true ? &_LoadTime_Loaded_RunTrue : 0;
}

_LoadTime_Loaded_RunTrue {
exec("wscript.exe \"".$_LoadTime_Path."\" 2") ;
togglepref( BOOL, "k-meleon_loadtime_active") ;
}
_LoadTime_BuildMenu{
setmenu("&Tools",macro,"LoadTime Test",LoadTime_RunCode,Misc);
}

_LoadTime_SetAccels{
setaccel("ALT l", "macros(LoadTime_RunCode)");
        }

_LoadTime_GetPath{
$__Data=readfile(getfolder(MacroFolder)."\\LoadTime.kmm");
$_LoadTime_Path=getfolder($__Data==""?UserMacroFolder:MacroFolder)."\\LoadTime.js";
}

$OnLoad=$OnLoad."_LoadTime_Loaded_Run;";
$OnStartup=$OnStartup."_LoadTime_GetPath;";
$OnInit=$OnInit."_LoadTime_BuildMenu;";
$OnInit=$OnInit."_LoadTime_SetAccels;";
$macroModules=$macroModules."LoadTime;";
 


LoadTime.js

/* LoadTimejs by JamesD, version 0.5 2008-10-05

This script is a helper application for the K-Meleon Macro Module LoadTime.kmm that
produces an elasped time for a page load.

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/
*/
var d, t ;
if(WScript.Arguments.count()==1)
{
var WshShell = new ActiveXObject("WScript.Shell")
if (WScript.Arguments(0) == 1)
{
d = new Date();
t = d.getTime();
WshShell.RegWrite ("HKCU\\Software\\KMELEON\\LoadTime\\start", t, "REG_SZ");
}
if (WScript.Arguments(0) == 2)
{
d = new Date();
t = d.getTime();
WshShell.RegWrite ("HKCU\\Software\\KMELEON\\LoadTime\\finish", t, "REG_SZ");
var $_LoadTime_Start = WshShell.RegRead ("HKCU\\Software\\KMELEON\\LoadTime\\start") ;
var $_LoadTime_Finish = WshShell.RegRead ("HKCU\\Software\\KMELEON\\LoadTime\\finish") ;
var $_LoadTime_Elapsed = $_LoadTime_Finish - $_LoadTime_Start ;
var $_LoadTime_Seconds = $_LoadTime_Elapsed / 1000 ;
WScript.Echo( $_LoadTime_Seconds + " Seconds elapsed time") ;
WshShell.RegDelete ("HKCU\\Software\\KMELEON\\LoadTime\\start") ;
WshShell.RegDelete ("HKCU\\Software\\KMELEON\\LoadTime\\finish") ;
}
}
else
{
objArgs = WScript.Arguments ;
WScript.Echo(WScript.Arguments.Count());
for (i=0; i<objArgs.length; i++)
{
WScript.Echo(objArgs(i))
}
}


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.