@secretlint/profiler
Advanced tools
Comparing version 0.7.0 to 0.7.1
# Change Log | ||
## 0.7.1 | ||
### Patch Changes | ||
- aaef596: Path Update | ||
All notable changes to this project will be documented in this file. | ||
@@ -10,6 +16,2 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
# [0.6.0](https://github.com/secretlint/secretlint/compare/v0.5.0...v0.6.0) (2020-02-29) | ||
@@ -19,6 +21,2 @@ | ||
# [0.5.0](https://github.com/secretlint/secretlint/compare/v0.4.2...v0.5.0) (2020-02-28) | ||
@@ -28,6 +26,2 @@ | ||
# [0.4.0](https://github.com/secretlint/secretlint/compare/v0.3.0...v0.4.0) (2020-02-28) | ||
@@ -37,6 +31,2 @@ | ||
# [0.3.0](https://github.com/secretlint/secretlint/compare/v0.2.0...v0.3.0) (2020-02-27) | ||
@@ -46,11 +36,6 @@ | ||
# [0.2.0](https://github.com/secretlint/secretlint/compare/v0.1.2...v0.2.0) (2020-02-23) | ||
### Features | ||
* **profiler:** add --profiler flag ([#40](https://github.com/secretlint/secretlint/issues/40)) ([0f86e54](https://github.com/secretlint/secretlint/commit/0f86e5415f0c249c6f5c2dfbf44465f0c58ce56e)) | ||
- **profiler:** add --profiler flag ([#40](https://github.com/secretlint/secretlint/issues/40)) ([0f86e54](https://github.com/secretlint/secretlint/commit/0f86e5415f0c249c6f5c2dfbf44465f0c58ce56e)) |
@@ -8,2 +8,20 @@ import perf_hooks from "perf_hooks"; | ||
} | { | ||
type: "@config-loader>load-packages::start"; | ||
} | { | ||
type: "@config-loader>load-packages::end"; | ||
} | { | ||
type: "@config-loader>load-config-file::start"; | ||
} | { | ||
type: "@config-loader>load-config-file::end"; | ||
} | { | ||
type: "@config-loader>resolve-module::start"; | ||
id: string; | ||
} | { | ||
type: "@config-loader>resolve-module::end"; | ||
id: string; | ||
} | { | ||
type: "@config-loader>resolve-modules::start"; | ||
} | { | ||
type: "@config-loader>resolve-modules::end"; | ||
} | { | ||
type: "@node>load-config::start"; | ||
@@ -54,5 +72,6 @@ } | { | ||
private measures; | ||
private executionPromise; | ||
private executionPromises; | ||
constructor(options: SecretLintProfilerOptions); | ||
mark(marker: SecretLintProfilerMarker): void; | ||
private waifForExecutionPromises; | ||
getEntries(): Promise<PerformanceEntry[]>; | ||
@@ -59,0 +78,0 @@ getMeasures(): Promise<PerformanceEntry[]>; |
@@ -44,3 +44,8 @@ "use strict"; | ||
this.measures = []; | ||
this.executionPromise = Promise.resolve(); | ||
this.executionPromises = []; | ||
this.waifForExecutionPromises = function () { | ||
return Promise.all(_this.executionPromises).finally(function () { | ||
_this.executionPromises.length = 0; | ||
}); | ||
}; | ||
this.perf = options.perf; | ||
@@ -64,5 +69,5 @@ var pattern = /(.*?)::end(\|\|.*)?/; | ||
// FIXME: avoid ERR_INVALID_PERFORMANCE_MARK error | ||
_this.executionPromise = Promise.resolve().then(function () { | ||
_this.executionPromises.push(Promise.resolve().then(function () { | ||
_this.perf.measure(endIdentifier_1 + suffix_1, endIdentifier_1 + "::start" + suffix_1, endIdentifier_1 + "::end" + suffix_1); | ||
}); | ||
})); | ||
} | ||
@@ -91,3 +96,3 @@ } | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.executionPromise]; | ||
case 0: return [4 /*yield*/, this.waifForExecutionPromises()]; | ||
case 1: | ||
@@ -104,3 +109,3 @@ _a.sent(); | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.executionPromise]; | ||
case 0: return [4 /*yield*/, this.waifForExecutionPromises()]; | ||
case 1: | ||
@@ -107,0 +112,0 @@ _a.sent(); |
112
package.json
{ | ||
"name": "@secretlint/profiler", | ||
"version": "0.7.0", | ||
"description": "Profile manager for Secretlint.", | ||
"keywords": [ | ||
"secretlint" | ||
], | ||
"homepage": "https://github.com/secretlint/secretlint/tree/master/packages/@secretlint/profiler/", | ||
"bugs": { | ||
"url": "https://github.com/secretlint/secretlint/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/secretlint/secretlint.git" | ||
}, | ||
"license": "MIT", | ||
"author": "azu", | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"src/" | ||
], | ||
"main": "lib/node.js", | ||
"browser": "lib/browser.js", | ||
"types": "lib/node.d.ts", | ||
"directories": { | ||
"lib": "lib", | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"build": "cross-env NODE_ENV=production tsc -p .", | ||
"clean": "rimraf lib/", | ||
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", | ||
"prepublish": "npm run --if-present build", | ||
"test": "#mocha \"test/**/*.ts\"", | ||
"watch": "tsc -p . --watch" | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"singleQuote": false, | ||
"tabWidth": 4 | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^7.0.1", | ||
"@types/node": "^13.7.4", | ||
"cross-env": "^7.0.0", | ||
"mocha": "^7.0.1", | ||
"prettier": "^1.19.1", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^8.6.2", | ||
"ts-node-test-register": "^8.0.1", | ||
"typescript": "^3.8.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "b29781cbb16259b05547b66b5a728f56c9ad9698" | ||
"name": "@secretlint/profiler", | ||
"version": "0.7.1", | ||
"description": "Profile manager for Secretlint.", | ||
"keywords": [ | ||
"secretlint" | ||
], | ||
"homepage": "https://github.com/secretlint/secretlint/tree/master/packages/@secretlint/profiler/", | ||
"bugs": { | ||
"url": "https://github.com/secretlint/secretlint/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/secretlint/secretlint.git" | ||
}, | ||
"license": "MIT", | ||
"author": "azu", | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"src/" | ||
], | ||
"main": "lib/node.js", | ||
"browser": "lib/browser.js", | ||
"types": "lib/node.d.ts", | ||
"directories": { | ||
"lib": "lib", | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"build": "cross-env NODE_ENV=production tsc -p .", | ||
"clean": "rimraf lib/", | ||
"prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", | ||
"prepublish": "npm run --if-present build", | ||
"test": "#mocha \"test/**/*.ts\"", | ||
"watch": "tsc -p . --watch" | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"singleQuote": false, | ||
"tabWidth": 4 | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^7.0.1", | ||
"@types/node": "^13.7.4", | ||
"cross-env": "^7.0.0", | ||
"mocha": "^7.0.1", | ||
"prettier": "^1.19.1", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^8.6.2", | ||
"ts-node-test-register": "^8.0.1", | ||
"typescript": "^3.8.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "ceffac0e71ed7bd2d20a518fbb74ecc6a9935161" | ||
} |
136
src/index.ts
@@ -6,62 +6,89 @@ import perf_hooks from "perf_hooks"; | ||
export type SecretLintProfilerMarker = | ||
// cli | ||
// cli | ||
| { | ||
type: "secretlint>cli::start"; | ||
} | ||
type: "secretlint>cli::start"; | ||
} | ||
| { | ||
type: "secretlint>cli::end"; | ||
} | ||
type: "secretlint>cli::end"; | ||
} | ||
// config-loader | ||
| { | ||
type: "@config-loader>load-packages::start"; | ||
} | ||
| { | ||
type: "@config-loader>load-packages::end"; | ||
} | ||
| { | ||
type: "@config-loader>load-config-file::start"; | ||
} | ||
| { | ||
type: "@config-loader>load-config-file::end"; | ||
} | ||
| { | ||
type: "@config-loader>resolve-module::start"; | ||
id: string; | ||
} | ||
| { | ||
type: "@config-loader>resolve-module::end"; | ||
id: string; | ||
} | ||
| { | ||
type: "@config-loader>resolve-modules::start"; | ||
} | ||
| { | ||
type: "@config-loader>resolve-modules::end"; | ||
} | ||
// node | ||
| { | ||
type: "@node>load-config::start"; | ||
} | ||
type: "@node>load-config::start"; | ||
} | ||
| { | ||
type: "@node>load-config::end"; | ||
} | ||
type: "@node>load-config::end"; | ||
} | ||
| { | ||
type: "@node>execute::start"; | ||
} | ||
type: "@node>execute::start"; | ||
} | ||
| { | ||
type: "@node>execute::end"; | ||
} | ||
type: "@node>execute::end"; | ||
} | ||
| { | ||
type: "@node>format::start"; | ||
} | ||
type: "@node>format::start"; | ||
} | ||
| { | ||
type: "@node>format::end"; | ||
} | ||
type: "@node>format::end"; | ||
} | ||
// core | ||
| { | ||
type: "@core>lint::start"; | ||
id: string; | ||
} | ||
type: "@core>lint::start"; | ||
id: string; | ||
} | ||
| { | ||
type: "@core>lint::end"; | ||
id: string; | ||
} | ||
type: "@core>lint::end"; | ||
id: string; | ||
} | ||
| { | ||
type: "@core>setup-rules::start"; | ||
} | ||
type: "@core>setup-rules::start"; | ||
} | ||
| { | ||
type: "@core>setup-rules::end"; | ||
} | ||
type: "@core>setup-rules::end"; | ||
} | ||
| { | ||
type: "@core>setup-rule::start"; | ||
id: string; | ||
} | ||
type: "@core>setup-rule::start"; | ||
id: string; | ||
} | ||
| { | ||
type: "@core>setup-rule::end"; | ||
id: string; | ||
} | ||
type: "@core>setup-rule::end"; | ||
id: string; | ||
} | ||
| { | ||
type: "@core>rule-handler::start"; | ||
id: string; | ||
} | ||
type: "@core>rule-handler::start"; | ||
id: string; | ||
} | ||
| { | ||
type: "@core>rule-handler::end"; | ||
id: string; | ||
}; | ||
type: "@core>rule-handler::end"; | ||
id: string; | ||
}; | ||
export type Constructor<I> = { | ||
new (...args: any[]): I; | ||
new(...args: any[]): I; | ||
}; | ||
@@ -78,3 +105,4 @@ export type SecretLintProfilerOptions = { | ||
private executionPromise = Promise.resolve(); | ||
private executionPromises: Promise<void>[] = []; | ||
constructor(options: SecretLintProfilerOptions) { | ||
@@ -99,9 +127,11 @@ this.perf = options.perf; | ||
// FIXME: avoid ERR_INVALID_PERFORMANCE_MARK error | ||
this.executionPromise = Promise.resolve().then(() => { | ||
this.perf.measure( | ||
endIdentifier + suffix, | ||
`${endIdentifier}::start${suffix}`, | ||
`${endIdentifier}::end${suffix}` | ||
); | ||
}); | ||
this.executionPromises.push( | ||
Promise.resolve().then(() => { | ||
this.perf.measure( | ||
endIdentifier + suffix, | ||
`${endIdentifier}::start${suffix}`, | ||
`${endIdentifier}::end${suffix}` | ||
); | ||
}) | ||
); | ||
} | ||
@@ -126,4 +156,10 @@ } | ||
private waifForExecutionPromises = () => { | ||
return Promise.all(this.executionPromises).finally(() => { | ||
this.executionPromises.length = 0; | ||
}); | ||
}; | ||
async getEntries() { | ||
await this.executionPromise; | ||
await this.waifForExecutionPromises(); | ||
return this.entries; | ||
@@ -133,5 +169,5 @@ } | ||
async getMeasures() { | ||
await this.executionPromise; | ||
await this.waifForExecutionPromises(); | ||
return this.measures; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21465
391