This commit is contained in:
Hem Brahmbhatt
2017-08-24 11:07:42 +01:00
parent 67c6ca08a6
commit 726b6dc4b3
3 changed files with 12 additions and 12 deletions

View File

@@ -90,7 +90,7 @@ module.exports = function (original, length, options) {
conf = {
original: original,
memoized: memoized,
profileName: options.profileName,
profileName: options.profileName,
get: function (args) {
if (resolve) args = resolve(args);
if (get) return get(args);

View File

@@ -15,16 +15,16 @@ var partial = require('es5-ext/function/#/partial')
Object.defineProperty(memoize, '__profiler__', d(function (conf) {
var id, source, data, stack;
stack = (new Error()).stack;
if (!stack || !stack.split('\n').slice(3).some(function (line) {
if ((line.indexOf('/memoizee/') === -1) &&
(line.indexOf(' (native)') === -1)) {
source = line.replace(/\n/g, "\\n").trim();
return true;
}
})) {
source = 'unknown';
}
id = compact.call([conf.profileName, source]).join(', ');
if (!stack || !stack.split('\n').slice(3).some(function (line) {
if ((line.indexOf('/memoizee/') === -1) &&
(line.indexOf(' (native)') === -1)) {
source = line.replace(/\n/g, "\\n").trim();
return true;
}
})) {
source = 'unknown';
}
id = compact.call([conf.profileName, source]).join(', ');
if (!stats[id]) stats[id] = { initial: 0, cached: 0 };
data = stats[id];

View File

@@ -4,7 +4,7 @@ var memoize = require('../plain');
module.exports = function (t, a) {
memoize(function () {})();
memoize(function () {}, { profileName: 'test' })();
memoize(function () {}, { profileName: 'test' })();
a(typeof t.statistics, 'object', "Access to statistics");
a(Object.keys(t.statistics).length, 2, "Statistics collected including named function");
a(typeof t.log, 'function', "Access to log function");