Add option "--timing" to mesure gitbook performances

This commit is contained in:
Samy Pesse
2016-04-30 14:37:44 +02:00
parent fbe0282738
commit 30bce5f9bb
10 changed files with 231 additions and 101 deletions
+22 -18
View File
@@ -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;
return timing.measure(
'parse.listPages',
walkSummary(summary, function(article) {
if (!article.isPage()) return;
var filepath = article.getPath();
var filepath = article.getPath();
// Is the page ignored?
if (book.isContentFileIgnored(filepath)) return;
// 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 fs.statFile(filepath)
.then(function(file) {
map = map.set(
filepath,
Page.createForFile(file)
);
}, function() {
// file doesn't exist
});
})
.then(function() {
return map;
})
);
}