diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-04-30 14:37:44 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-04-30 14:37:44 +0200 |
commit | 30bce5f9bb1f8ceee867770386fa6f7fdffd27ee (patch) | |
tree | 8470737d295aa6c4c7f861b1553d50bce34a9936 /lib/parse/parsePagesList.js | |
parent | fbe028273828bc8518e92e87fcbd2a6718dc91e2 (diff) | |
download | gitbook-30bce5f9bb1f8ceee867770386fa6f7fdffd27ee.zip gitbook-30bce5f9bb1f8ceee867770386fa6f7fdffd27ee.tar.gz gitbook-30bce5f9bb1f8ceee867770386fa6f7fdffd27ee.tar.bz2 |
Add option "--timing" to mesure gitbook performances
Diffstat (limited to 'lib/parse/parsePagesList.js')
-rw-r--r-- | lib/parse/parsePagesList.js | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/lib/parse/parsePagesList.js b/lib/parse/parsePagesList.js index e356e88..a3a52f8 100644 --- a/lib/parse/parsePagesList.js +++ b/lib/parse/parsePagesList.js @@ -1,5 +1,6 @@ var Immutable = require('immutable'); +var timing = require('../utils/timing'); var Page = require('../models/page'); var walkSummary = require('./walkSummary'); @@ -14,27 +15,30 @@ function parsePagesList(book) { var summary = book.getSummary(); var map = Immutable.OrderedMap(); - return walkSummary(summary, function(article) { - if (!article.isPage()) return; - - var filepath = article.getPath(); - - // Is the page ignored? - if (book.isContentFileIgnored(filepath)) return; - - return fs.statFile(filepath) - .then(function(file) { - map = map.set( - filepath, - Page.createForFile(file) - ); - }, function() { - // file doesn't exist - }); - }) - .then(function() { - return map; - }); + return timing.measure( + 'parse.listPages', + walkSummary(summary, function(article) { + if (!article.isPage()) return; + + var filepath = article.getPath(); + + // Is the page ignored? + if (book.isContentFileIgnored(filepath)) return; + + return fs.statFile(filepath) + .then(function(file) { + map = map.set( + filepath, + Page.createForFile(file) + ); + }, function() { + // file doesn't exist + }); + }) + .then(function() { + return map; + }) + ); } |