prepack
Version:
Execute a JS bundle, serialize global state and side effects to a snapshot that can be quickly restored.
103 lines (93 loc) • 4.79 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SerializerStatistics = void 0;
var _statistics = require("../statistics.js");
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* strict-local */
class SerializerStatistics extends _statistics.RealmStatistics {
constructor(getTime, getMemory, forcingGC = false) {
super(getTime, getMemory);
this.forcingGC = forcingGC;
this.functions = 0;
this.delayedValues = 0;
this.initializedModules = 0;
this.acceleratedModules = 0;
this.delayedModules = 0;
this.totalModules = 0;
this.resetBeforePass();
this.total = new _statistics.PerformanceTracker(getTime, getMemory);
this.resolveInitializedModules = new _statistics.PerformanceTracker(getTime, getMemory);
this.modulesToInitialize = new _statistics.PerformanceTracker(getTime, getMemory);
this.optimizeReactComponentTreeRoots = new _statistics.PerformanceTracker(getTime, getMemory);
this.checkThatFunctionsAreIndependent = new _statistics.PerformanceTracker(getTime, getMemory);
this.processCollectedNestedOptimizedFunctions = new _statistics.PerformanceTracker(getTime, getMemory);
this.deepTraversal = new _statistics.PerformanceTracker(getTime, getMemory);
this.referentialization = new _statistics.PerformanceTracker(getTime, getMemory);
this.referenceCounts = new _statistics.PerformanceTracker(getTime, getMemory);
this.serializePass = new _statistics.PerformanceTracker(getTime, getMemory);
this.babelGenerate = new _statistics.PerformanceTracker(getTime, getMemory);
this.dumpIR = new _statistics.PerformanceTracker(getTime, getMemory);
}
resetBeforePass() {
this.objects = 0;
this.objectProperties = 0;
this.functionClones = 0;
this.lazyObjects = 0;
this.referentialized = 0;
this.valueIds = 0;
this.valuesInlined = 0;
this.generators = 0;
this.requireCalls = 0;
this.requireCallsReplaced = 0;
}
// legacy projection
getSerializerStatistics() {
return {
objects: this.objects,
objectProperties: this.objectProperties,
functions: this.functions,
functionClones: this.functionClones,
lazyObjects: this.lazyObjects,
referentialized: this.referentialized,
valueIds: this.valueIds,
valuesInlined: this.valuesInlined,
delayedValues: this.delayedValues,
initializedModules: this.initializedModules,
acceleratedModules: this.acceleratedModules,
delayedModules: this.delayedModules,
totalModules: this.totalModules,
generators: this.generators,
requireCalls: this.requireCalls,
requireCallsReplaced: this.requireCallsReplaced
};
}
log() {
super.log();
console.log(`=== serialization statistics`);
console.log(`${this.objects} objects with ${this.objectProperties} properties`);
console.log(`${this.functions} functions plus ${this.functionClones} clones due to captured variables; ${this.referentialized} captured mutable variables`);
console.log(`${this.lazyObjects} objects are lazy.`);
console.log(`${this.valueIds} eager and ${this.delayedValues} delayed value ids generated, and ${this.valuesInlined} values inlined.`);
console.log(`${this.initializedModules} out of ${this.totalModules} modules initialized, with ${this.acceleratedModules} accelerated and ${this.delayedModules} delayed.`);
console.log(`${this.requireCallsReplaced} of ${this.requireCalls} require calls inlined.`);
console.log(`${this.generators} generators`);
}
logSerializerPerformanceTrackers(title, note, format) {
console.log(`=== ${title}: ${format(this.total)} total`);
if (note !== undefined) console.log(`NOTE: ${note}`);
this.logPerformanceTrackers(format);
console.log(`${format(this.resolveInitializedModules)} resolving initialized modules, ${format(this.modulesToInitialize)} initializing more modules, ${format(this.optimizeReactComponentTreeRoots)} optimizing react component tree roots, ${format(this.checkThatFunctionsAreIndependent)} evaluating functions to optimize, ${format(this.dumpIR)} dumping IR`);
console.log(`${format(this.deepTraversal)} visiting residual heap, ${format(this.referentialization)} referentializing functions, ${format(this.referenceCounts)} reference counting, ${format(this.serializePass)} generating AST, ${format(this.babelGenerate)} generating source code`);
}
}
exports.SerializerStatistics = SerializerStatistics;
//# sourceMappingURL=statistics.js.map