Last Comment Bug 932609 - GCLI: add a command to measure the memory consumption of the current tab
: GCLI: add a command to measure the memory consumption of the current tab
Status: RESOLVED WONTFIX
:
Product: Firefox
Classification: Client Software
Component: Developer Tools: Graphic Commandline and Toolbar (show other bugs)
: unspecified
: x86_64 Linux
: -- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-29 18:20 PDT by Nicholas Nethercote [:njn]
Modified: 2016-02-18 06:56 PST (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description Nicholas Nethercote [:njn] 2013-10-29 18:20:17 PDT
Bug 918207 has a draft patch that invokes sizeOfTab and prints the half dozen or so numbers in a short-lived box that sits above the GCLI (I don't know what the correct term for that box is).

The patch needs some cleaning up.  And is there a better way to show its output?
Comment 1 Joe Walker [:jwalker] (needinfo me or ping on irc) 2013-10-30 02:15:22 PDT
(In reply to Nicholas Nethercote [:njn] from comment #0)
> Bug 918207 has a draft patch that invokes sizeOfTab and prints the half
> dozen or so numbers in a short-lived box that sits above the GCLI (I don't
> know what the correct term for that box is).
> 
> The patch needs some cleaning up.  And is there a better way to show its
> output?

Nice. There is a better way to format output that confers 2 benefits:
* HTML formatted output
* The potential ability to pipe the output of this command to something that consumes the values without needing to scrape data

The method you have right now works just fine - I wouldn't reject it because the output was a string, and I have a plan to go through BuiltinCommands doing a tidy-up so that might be a good time to do it.
Comment 2 Nicholas Nethercote [:njn] 2013-10-30 02:19:59 PDT
> There is a better way to format output

And what is that way?  Is there an existing command I can look at for ideas?
Comment 3 Joe Walker [:jwalker] (needinfo me or ping on irc) 2013-10-31 07:14:34 PDT
The 'cookie list' command is probably the best example [1]:

  gcli.addCommand({
    name: "cookie list",
    ...
    returnType: "cookies",
    exec: function(args, context) {
      // ...
      let enm = cookieMgr.getCookiesFromHost(host);

      let cookies = [];
      while (enm.hasMoreElements()) {
        let cookie = enm.getNext().QueryInterface(Ci.nsICookie);
        cookies.push({
          host: cookie.host,
          name: cookie.name,
          value: cookie.value,
          path: cookie.path
        });
      }

      return cookies;
    }
  });

i.e. the return type is 'cookies' and it returns a JSONable blob of data

Then there is a converter from 'cookies' to HTML [2], where the important bits are:

  gcli.addConverter({
    from: "cookies",
    to: "view",
    exec: function(cookies, context) {
      //...
      return context.createView({
        html: cookieListHtml,
        data: {
          cookies: cookies
        }
      });
    }
  });

And cookieListHtml is defined a bit earlier [3].

The official docs [4] might also be useful, but they're light on converters, and there's good documentation on the template system at [5].

[1]: http://mxr.mozilla.org/mozilla-central/source/browser/devtools/commandline/BuiltinCommands.jsm#980
[2]: http://mxr.mozilla.org/mozilla-central/source/browser/devtools/commandline/BuiltinCommands.jsm#914
[3]: http://mxr.mozilla.org/mozilla-central/source/browser/devtools/commandline/BuiltinCommands.jsm#879
[4]: https://github.com/joewalker/gcli/blob/master/docs/index.md
[5]: https://github.com/joewalker/domtemplate
Comment 4 Joe Walker [:jwalker] (needinfo me or ping on irc) 2016-02-18 06:56:14 PST
Triage. Filter on Lobster Thermidor.
Nice idea, but it's not been worked on in 4 years, and I don't see that the priority of GCLI has increased in that time, so I don't think we need to keep it on file.

Note You need to log in before you can comment on or make changes to this bug.