mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 14:27:58 +01:00
merge new :time command
This commit is contained in:
5
NEWS
5
NEWS
@@ -2,9 +2,10 @@
|
|||||||
2007-XX-XX:
|
2007-XX-XX:
|
||||||
* version 0.5.2
|
* version 0.5.2
|
||||||
* added 'visualbellstyle' for styling/hiding the visual bell
|
* added 'visualbellstyle' for styling/hiding the visual bell
|
||||||
* :buffer partial_string works now as in vim, and with ! even better
|
|
||||||
* merge the existing status bar with the standard FF status bar so that
|
* merge the existing status bar with the standard FF status bar so that
|
||||||
security information and extension buttons are included
|
security information and extension buttons are included
|
||||||
|
* :buffer partial_string works now as in vim, and with ! even better
|
||||||
|
* new :time command for profiling
|
||||||
* added new :sidebar and :sbclose commands
|
* added new :sidebar and :sbclose commands
|
||||||
* added 'more' and standard more-prompt key mappings to control
|
* added 'more' and standard more-prompt key mappings to control
|
||||||
behaviour of the message list pager
|
behaviour of the message list pager
|
||||||
@@ -12,7 +13,9 @@
|
|||||||
highlighted text strings when 'hlsearch' is set
|
highlighted text strings when 'hlsearch' is set
|
||||||
* added 'linksearch' option to restrict page searches to link text - \U
|
* added 'linksearch' option to restrict page searches to link text - \U
|
||||||
and \u can be used in the search pattern to override 'linksearch'
|
and \u can be used in the search pattern to override 'linksearch'
|
||||||
|
* vimperator trys to stay in command mode after loading pages instead of having a text field focused
|
||||||
* added a visual bell and replaced 'beep' with 'visualbell'
|
* added a visual bell and replaced 'beep' with 'visualbell'
|
||||||
|
* added vimperator logo (can be seen in the addons manager)
|
||||||
* added 'hlsearch','incsearch', 'ignorecase' and 'smartcase' options
|
* added 'hlsearch','incsearch', 'ignorecase' and 'smartcase' options
|
||||||
|
|
||||||
2007-09-03:
|
2007-09-03:
|
||||||
|
|||||||
@@ -1251,6 +1251,85 @@ function Commands() //{{{
|
|||||||
short_help: "Switch to the first tab"
|
short_help: "Switch to the first tab"
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
addDefaultCommand(new Command(["time"],
|
||||||
|
function(args, special, count)
|
||||||
|
{
|
||||||
|
if (!count || count < 1)
|
||||||
|
count = 1;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (count > 1)
|
||||||
|
{
|
||||||
|
var i = count;
|
||||||
|
var before_time = Date.now();
|
||||||
|
|
||||||
|
if (args && args[0] == ":")
|
||||||
|
while (i--)
|
||||||
|
vimperator.execute(args);
|
||||||
|
else
|
||||||
|
while (i--)
|
||||||
|
eval(args);
|
||||||
|
|
||||||
|
if (special)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var after_time = Date.now();
|
||||||
|
|
||||||
|
if ((after_time - before_time) / count >= 100)
|
||||||
|
var each = " Each time: <span style=\"color: green\">" +
|
||||||
|
((after_time - before_time) / 1000.0 / count) +
|
||||||
|
"</span> sec<br/>";
|
||||||
|
else
|
||||||
|
var each = " Each time: <span style=\"color: green\">" +
|
||||||
|
((after_time - before_time) / count) +
|
||||||
|
"</span> msec<br/>";
|
||||||
|
|
||||||
|
if (after_time - before_time >= 100)
|
||||||
|
var total = " Total time: <span style=\"color: red\">" +
|
||||||
|
((after_time - before_time) / 1000.0) +
|
||||||
|
"</span> sec";
|
||||||
|
else
|
||||||
|
var total = " Total time: <span style=\"color: red\">" +
|
||||||
|
(after_time - before_time) + "</span> msec";
|
||||||
|
|
||||||
|
|
||||||
|
vimperator.echo("<span style=\"color: magenta; font-weight: bold\">Code execution summary</span>:<br/>" +
|
||||||
|
" Executed: <span style=\"color: green\">" + count + "</span> times<br/>" + each + total);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var before_time = Date.now();
|
||||||
|
if (args && args[0] == ":")
|
||||||
|
vimperator.execute(args);
|
||||||
|
else
|
||||||
|
eval(args);
|
||||||
|
|
||||||
|
if (special)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var after_time = Date.now();
|
||||||
|
|
||||||
|
if (after_time - before_time >= 100)
|
||||||
|
vimperator.echo("Total time: " + ((after_time - before_time) / 1000.0) + " sec");
|
||||||
|
else
|
||||||
|
vimperator.echo("Total time: " + (after_time - before_time) + " msec");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e)
|
||||||
|
{
|
||||||
|
vimperator.echoerr(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
usage: ["{count}time[!] {code|:command}"],
|
||||||
|
short_help: "Profile a piece of code or a command",
|
||||||
|
help: "Runs <code class=\"argument\">{code} {count}</code> times (default 1) and returns the elapsed time. " +
|
||||||
|
"<code class=\"argument\">{code}</code> is always passed to JavaScript's eval(), which might be slow, so take the results with a grain of salt.<br/>" +
|
||||||
|
"If <code class=\"argument\">{code}</code> starts with a :, it is executed as a vimperator command.<br/>" +
|
||||||
|
"Use the special version with [!] if you just want to run any command multiple times without showing profiling statistics."
|
||||||
|
}
|
||||||
|
));
|
||||||
addDefaultCommand(new Command(["u[ndo]"],
|
addDefaultCommand(new Command(["u[ndo]"],
|
||||||
function(args, special, count) { if (count < 1) count = 1; undoCloseTab(count-1); },
|
function(args, special, count) { if (count < 1) count = 1; undoCloseTab(count-1); },
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user