UNPKG

@typescript/analyze-trace

Version:
41 lines 2.05 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs"); const exit = require("exit"); const yargs = require("yargs"); const analyze_trace_options_1 = require("./analyze-trace-options"); const print_trace_analysis_text_1 = require("./print-trace-analysis-text"); const print_trace_analysis_json_1 = require("./print-trace-analysis-json"); const argv = yargs(process.argv.slice(2)) .command("$0 <tracePath> [typesPath]", "Preprocess tracing type dumps", yargs => yargs .positional("tracePath", { type: "string", desc: "Trace file to read", coerce: throwIfNotFile }) .positional("typesPath", { type: "string", desc: "Corresponding types file", coerce: throwIfNotFile }) .options(analyze_trace_options_1.commandLineOptions) .check(analyze_trace_options_1.checkCommandLineOptions) .help("h").alias("h", "help") .epilog("Exits with code 0 if highlights were found, 1 if no highlights were found, and 2 if an error occurred") .strict()) .argv; const tracePath = argv.tracePath; const typesPath = argv.typesPath; const thresholdDuration = argv.forceMillis * 1000; // microseconds const minDuration = argv.skipMillis * 1000; // microseconds const minPercentage = 0.6; const importExpressionThreshold = 10; const reportHighlights = argv.json ? print_trace_analysis_json_1.reportHighlights : print_trace_analysis_text_1.reportHighlights; reportHighlights(tracePath, argv.expandTypes ? typesPath : undefined, thresholdDuration, minDuration, minPercentage, importExpressionThreshold) .then(found => exit(found ? 0 : 1)) .catch(err => { console.error(`Internal Error: ${err.message}\n${err.stack}`); exit(2); }); function throwIfNotFile(path) { var _a; if (!fs.existsSync(path) || !((_a = fs.statSync(path)) === null || _a === void 0 ? void 0 : _a.isFile())) { throw new Error(`${path} is not a file`); } return path; } //# sourceMappingURL=analyze-trace-file.js.map