UNPKG

2.34 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const path_1 = require("@stoplight/path");
5const fs = require("fs");
6const filesystem_1 = require("./backends/filesystem");
7const nodes_1 = require("./graph/nodes");
8const graphite_1 = require("./graphite");
9const json_1 = require("./plugins/json");
10const json_schema_1 = require("./plugins/json-schema");
11const oas2_1 = require("./plugins/oas2");
12const oas3_1 = require("./plugins/oas3");
13const yaml_1 = require("./plugins/yaml");
14const cwdOptions = {
15 fixtures: path_1.resolve(__dirname, '..', '..', 'graphite-simple', 'fixtures'),
16 dev: path_1.resolve(__dirname, '..', '..'),
17};
18const demos = {
19 file: path_1.join('example', 'api.oas2.json'),
20 small: path_1.join('example'),
21 crux: path_1.join('crux'),
22 huge: path_1.join('openapi-directory', 'APIs', 'azure.com'),
23 insane: path_1.join('openapi-directory'),
24 stoplight_workspace: path_1.join('.'),
25};
26const cwd = cwdOptions.fixtures;
27const target = demos.huge;
28const mirror = false;
29const dir = path_1.join(cwd, target);
30const graphite = graphite_1.createGraphite();
31graphite.registerPlugins(json_1.createJsonPlugin(), yaml_1.createYamlPlugin(), oas2_1.createOas2Plugin(), json_schema_1.createJsonSchemaPlugin(), oas3_1.createOas3Plugin());
32const run = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
33 console.log('start!');
34 graphite.graph.addNode({
35 category: nodes_1.NodeCategory.Source,
36 type: filesystem_1.FilesystemNodeType.Directory,
37 path: dir,
38 });
39 filesystem_1.createFileSystemBackend(graphite, fs).readdir(dir);
40 yield graphite.scheduler.drain();
41 console.log(`resulting graph:
42 - ${graphite.graph.sourceNodes.filter(n => n.type === filesystem_1.FilesystemNodeType.Directory).length} directory nodes
43 - ${graphite.graph.sourceNodes.filter(n => n.type === filesystem_1.FilesystemNodeType.File).length} document nodes
44 - ${graphite.graph.nodeValues.filter(n => n.category === nodes_1.NodeCategory.SourceMap || n.category === nodes_1.NodeCategory.Virtual)
45 .length} symbol nodes
46`);
47 const used = process.memoryUsage().heapUsed / 1024 / 1024;
48 console.log(`The script used approximately ${Math.round(used)} MB of memory`);
49});
50run();
51//# sourceMappingURL=benchmark.js.map
\No newline at end of file