From d3749485befaeaa477af8d1f3af215eb67243e8b Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Fri, 29 Jan 2016 22:45:25 -0800 Subject: [PATCH] Profile a few more things --- packages/babel-compiler/babel-compiler.js | 12 +++++++++++- tools/fs/files.js | 4 ++++ tools/isobuild/compiler.js | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/babel-compiler/babel-compiler.js b/packages/babel-compiler/babel-compiler.js index e7e159f8ee..4f96c5407a 100644 --- a/packages/babel-compiler/babel-compiler.js +++ b/packages/babel-compiler/babel-compiler.js @@ -59,7 +59,9 @@ BCp.processFilesForTarget = function (inputFiles) { babelOptions.sourceMapTarget = babelOptions.filename + ".map"; try { - var result = Babel.compile(source, babelOptions); + var result = profile('Babel.compile', function () { + return Babel.compile(source, babelOptions); + }); } catch (e) { if (e.loc) { inputFile.error({ @@ -86,3 +88,11 @@ BCp.processFilesForTarget = function (inputFiles) { BCp.setDiskCacheDirectory = function (cacheDir) { Babel.setCacheDir(cacheDir); }; + +function profile(name, func) { + if (typeof Profile !== 'undefined') { + return Profile.time(name, func); + } else { + return func(); + } +}; diff --git a/tools/fs/files.js b/tools/fs/files.js index cfc79290b2..f6256ff168 100644 --- a/tools/fs/files.js +++ b/tools/fs/files.js @@ -823,6 +823,8 @@ files.renameDirAlmostAtomically = function (fromDir, toDir) { files.rm_recursive(garbageDir); } }; +files.renameDirAlmostAtomically = Profile("files.renameDirAlmostAtomically", + files.renameDirAlmostAtomically); files.writeFileAtomically = function (filename, contents) { var tmpFile = files.pathJoin( @@ -831,6 +833,8 @@ files.writeFileAtomically = function (filename, contents) { files.writeFile(tmpFile, contents); files.rename(tmpFile, filename); }; +files.writeFileAtomically = Profile("files.writeFileAtomically", + files.writeFileAtomically); // Like fs.symlinkSync, but creates a temporay link and renames it over the // file; this means it works even if the file already exists. diff --git a/tools/isobuild/compiler.js b/tools/isobuild/compiler.js index b2bfd40545..9fcf4d3d53 100644 --- a/tools/isobuild/compiler.js +++ b/tools/isobuild/compiler.js @@ -323,7 +323,7 @@ var lintUnibuild = function ({isopack, isopackCache, sourceArch}) { // options.isopack. // // Returns a list of source files that were used in the compilation. -var compileUnibuild = function (options) { +var compileUnibuild = Profile("compileUnibuild", function (options) { buildmessage.assertInCapture(); const isopk = options.isopack; @@ -609,7 +609,7 @@ api.addAssets('${relPath}', 'client').`); return { pluginProviderPackageNames: pluginProviderPackageNames }; -}; +}); function runLinters({inputSourceArch, isopackCache, sources, sourceProcessorSet, watchSet}) {