UNPKG

@nxworker/workspace

Version:

Nx plugin providing generators for managing workspace files, including the move-file generator for safely moving files between projects while updating all imports

55 lines (54 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _tinybenchutils = require("../../../../../../tools/tinybench-utils"); const _testing = require("@nx/devkit/testing"); const _cachedtreeexists = require("../cache/cached-tree-exists"); const _getprojectsourcefiles = require("../cache/get-project-source-files"); const _updateprojectsourcefilescache = require("../cache/update-project-source-files-cache"); let fileExistenceCache; let projectRoot; let projectSourceFilesCache; let tree; let testFiles; (0, _tinybenchutils.benchmarkSuite)('Cache Operations', { 'Cache hit': { fn: ()=>{ testFiles.forEach((file)=>(0, _cachedtreeexists.cachedTreeExists)(tree, file, fileExistenceCache)); }, warmup: true, warmupIterations: 1 }, 'Cache miss': ()=>{ testFiles.forEach((file)=>(0, _cachedtreeexists.cachedTreeExists)(tree, file, fileExistenceCache)); }, 'Source file retrieval': { fn: ()=>{ (0, _getprojectsourcefiles.getProjectSourceFiles)(tree, projectRoot, projectSourceFilesCache, fileExistenceCache); }, warmup: true, warmupIterations: 1 }, 'Cache update': ()=>{ const oldPath = `${projectRoot}/src/lib/old.ts`; const newPath = `${projectRoot}/src/lib/new.ts`; (0, _updateprojectsourcefilescache.updateProjectSourceFilesCache)(projectRoot, oldPath, newPath, projectSourceFilesCache); } }, { setupSuite () { fileExistenceCache = new Map(); projectRoot = 'libs/test-lib'; projectSourceFilesCache = new Map(); tree = (0, _testing.createTreeWithEmptyWorkspace)(); testFiles = Array.from({ length: 100 }, (_, i)=>`${projectRoot}/src/lib/file-${i}.ts`); testFiles.forEach((file)=>tree.write(file, 'export {};')); }, teardown () { fileExistenceCache.clear(); projectSourceFilesCache.clear(); } }); //# sourceMappingURL=cache-operations.bench.js.map