@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
76 lines • 3.41 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadBenchmarkData = loadBenchmarkData;
exports.getLatestBenchmark = getLatestBenchmark;
exports.getLastBenchmarkUpdate = getLastBenchmarkUpdate;
exports.getLatestDfAnalysisTime = getLatestDfAnalysisTime;
const path_1 = __importDefault(require("path"));
const assert_1 = require("../../util/assert");
const BenchmarkDataPath = path_1.default.resolve(__dirname, '..', '..', '..', 'wiki', 'stats', 'benchmark', 'data.js');
let benchmarkData = null;
async function loadBenchmarkData() {
if (benchmarkData === null) {
// provide a window object to attach to in the import
globalThis['window'] = {};
await Promise.resolve(`${BenchmarkDataPath}`).then(s => __importStar(require(s)));
// @ts-expect-error -- we know that the data is there
benchmarkData = window['BENCHMARK_DATA'];
}
return benchmarkData;
}
async function getLatestBenchmark(suite) {
// provide a window object to attach to in the import
const suiteData = (await loadBenchmarkData()).entries[suite];
(0, assert_1.guard)(suiteData, `No benchmark data for suite '${suite}' found!`);
return suiteData.sort((a, b) => b.date - a.date)[0];
}
async function getLastBenchmarkUpdate() {
return (await loadBenchmarkData()).lastUpdate;
}
function getBenchmarkElement(bench, name) {
const element = bench.benches.find(b => b.name === name);
(0, assert_1.guard)(element, `No benchmark data for '${name}' found!`);
return element;
}
async function getLatestDfAnalysisTime(suite) {
const elem = await getLatestBenchmark(suite);
const [parse, normalize, analyze] = ['Retrieve AST from R code', 'Normalize R AST', 'Produce dataflow information'].map(name => getBenchmarkElement(elem, name));
return parse.value + normalize.value + analyze.value;
}
//# sourceMappingURL=doc-benchmarks.js.map