Alias / Command shortcut on Meteor Shell for performance debug

So, I’ve been learning meteor lately and to test some functions execution and optimize my app, I’m using some basic javascript timing functions on the meteor shell, such as:

console.time("code1");someFunction();console.timeEnd("code1");

Works pretty well… now I’m wondering if I can wrap this into a single command on the meteor shell something like:

performance somefunction();

Not something really important, just wondering what can I do with the framework to optimize my workflow.

You could create a global server only utilities object, then reference it from the console. Something like:

/server/console_utils.js

ConsoleUtils = {
  timing(someFunction) {
    const timingLabel = `${someFunction.name} timing`;
    console.time(timingLabel);
    someFunction();
    console.timeEnd(timingLabel);
  }
};

You could then call it from the console like:

ConsoleUtils.timing(someFunction);