Created
May 19, 2011 08:23
-
-
Save teramako/980396 to your computer and use it in GitHub Desktop.
[Vimperator Plugin]about:memory のようなものを出力する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commands.addUserCommand(["memory[reports]"], "show memory reports", | |
show, | |
{}, | |
true); | |
function getMemoryInfo () { | |
const MRM = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager); | |
var data = [], | |
reports = MRM.enumerateReporters(); | |
while (reports.hasMoreElements()) { | |
var {description, path, memoryUsed} = reports.getNext().QueryInterface(Ci.nsIMemoryReporter); | |
yield [description, path, memoryUsed]; | |
} | |
} | |
function show () { | |
var x = | |
<table width="100%"> | |
<tr highlight="Title"> | |
<th>Path</th> | |
<th>Used</th> | |
<th>Description</th> | |
</tr> | |
</table> | |
for (let [desc, path, used] in getMemoryInfo()) { | |
x.appendChild(<tr> | |
<td>{path}</td> | |
<td>{util.formatBytes(used, 1, true)}</td> | |
<td>{desc}</td> | |
</tr>); | |
} | |
liberator.echo(<><style type="text/css"><![CDATA[ | |
table { background-color: white; } | |
th,td { border: thin solid gray; } | |
td:nth-child(2) { text-align: right; } | |
tr:nth-child(odd) { background-color: rgb(240, 248, 255); } | |
]]></style> | |
{x}</>, true); | |
} | |
// vim: sw=2 ts=2 et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment