return Q.all(links.map(function(link) { var def = Q.defer(), bemjson = FS.readFileSync(link , 'UTF-8'), bemhtml = link.replace(/.bemjson.js/, '.bemhtml.js'), bh = link.replace(/.bemjson.js/, '.bh.js'), context = VM.createContext({}), res = VM.runInContext(bemjson, context, link), name = link.match(/([^\/]+)$/)[0], nameShort = name.replace('.bemjson.js',''), suite = new BENCHMARK.Suite(), results = [], isBh = false, isBemhtml = false, label = '[' + target.green + ' => ' + nameShort.blue + '] has been tested'; LOGGER.time(label); if (U.isFile(bemhtml)) { if (!self.techs || self.techs.indexOf('bemhtml') !== -1) { bemhtml = require(bemhtml); isBemhtml = true; } } if (U.isFile(bh)) { if (!self.techs || self.techs.indexOf('bh') !== -1) { bh = require(bh); isBh = true; } } // Warming-up for the best results (function() { var i = self.WARMING_CYCLE; while (i--) { if (isBemhtml) bemhtml.BEMHTML.apply(res); if (isBh) bh.INST.apply(res); } })(); if (isBh) { suite.add(name + '(bh)'.underline, function() { bh.INST.apply(res); }); } if (isBemhtml) { suite.add(name + '(bemhtml)'.underline, function() { bemhtml.BEMHTML.apply(res); }); } suite .on('cycle', function(event) { results.push({ 'name' : String(event.target.name), 'hz' : Number(Math.round(event.target.hz) / 1000).toFixed(1), 'rme' : Number(event.target.stats.rme).toFixed(1), 'runs' : event.target.stats.sample.length, 'isSeparator' : isBemhtml && isBh }); }) .on('complete', function(event) { LOGGER.timeEnd(label); def.resolve(results); }) .on('error', function(err) { def.reject(err); }) .run({ 'async': false }); return def.promise; }))