Compare commits

..

No commits in common. "master" and "v4.0.4" have entirely different histories.

5 changed files with 43 additions and 125 deletions

View File

@ -6,23 +6,12 @@
"gitzone": { "gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "code.foss.global", "githost": "gitlab.com",
"gitscope": "push.rocks", "gitscope": "push.rocks",
"gitrepo": "early", "gitrepo": "early",
"description": "A plugin for measuring startup time with minimal performance impact.", "description": "minimal and fast loading plugin for startup time measuring",
"npmPackagename": "@push.rocks/early", "npmPackagename": "@push.rocks/early",
"license": "MIT", "license": "MIT"
"keywords": [
"performance measurement",
"startup time",
"high resolution timer",
"plugin",
"typescript",
"nodejs"
]
} }
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
} }
} }

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/early", "name": "@push.rocks/early",
"version": "4.0.4", "version": "4.0.4",
"private": false, "private": false,
"description": "A plugin for measuring startup time with minimal performance impact.", "description": "minimal and fast loading plugin for startup time measuring",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
@ -13,22 +13,17 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://code.foss.global/push.rocks/early.git" "url": "git+https://gitlab.com/pushrocks/early.git"
}, },
"keywords": [ "keywords": [
"performance measurement", "preloader"
"startup time",
"high resolution timer",
"plugin",
"typescript",
"nodejs"
], ],
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/early/issues" "url": "https://gitlab.com/pushrocks/early/issues"
}, },
"homepage": "https://code.foss.global/push.rocks/early", "homepage": "https://gitlab.com/pushrocks/early#readme",
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.66", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44", "@gitzone/tsrun": "^1.2.44",
@ -56,4 +51,4 @@
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
] ]
} }

View File

@ -1 +0,0 @@

131
readme.md
View File

@ -1,114 +1,49 @@
# @push.rocks/early # @push.rocks/early
minimal and fast loading plugin for startup time measuring minimal and fast loading plugin for startup time measuring
## Install ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/early)
* [gitlab.com (source)](https://gitlab.com/push.rocks/early)
* [github.com (source mirror)](https://github.com/push.rocks/early)
* [docs (typedoc)](https://push.rocks.gitlab.io/early/)
To install `@push.rocks/early`, run the following command in your terminal: ## Status for master
```bash Status Category | Status Badge
npm install @push.rocks/early --save -- | --
``` GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/early/badges/master/pipeline.svg)](https://lossless.cloud)
This will add `@push.rocks/early` to your project's dependencies and prepare it for use. GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/early/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/early)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/early)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/early)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/early)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/early)](https://lossless.cloud)
## Usage ## Usage
In this guide, we'll explore how to use `@push.rocks/early` to measure startup times in your application. This tool is designed to be minimal and fast, providing accurate measurements of how long it takes for parts of your application to load. Use TypeScript for best in class instellisense.
### Getting Started with `@push.rocks/early` ```javascript
// Put the following at the start of your module
First, ensure that your project is set up with TypeScript and that you are familiar with working with ES modules. `@push.rocks/early` is built with TypeScript in mind, offering excellent IntelliSense support in compatible editors. import * as early from 'early';
#### Importing `@push.rocks/early`
To begin, import the library into your module:
```typescript
import * as early from '@push.rocks/early';
```
#### Starting Measurement
The first step in using `@push.rocks/early` is to start the measurement. This should be done as early as possible in your application's startup sequence:
```typescript
early.start('myModuleName'); early.start('myModuleName');
``` /*
Replace `'myModuleName'` with a string identifier for the module or application part you are measuring. This is purely for identification purposes and aids in debugging or logging. do your loading stuff
*/
#### Performing Your Loading Operations
After starting the measurement, proceed with the operations or loading tasks you wish to measure. This could involve loading modules, reading files, or any setup tasks required for your application to start:
```typescript
// Example loading operations
await myModule.initialize();
await myOtherModule.loadConfig();
```
#### Stopping Measurement and Retrieving Results
Once your loading operations are complete, stop the measurement to retrieve the loading time:
```typescript
early.stop().then((loadingTime: number) => { early.stop().then((loadingTime: number) => {
console.log(`Loading time: ${loadingTime} milliseconds`); // loadingTime in milliseconds
}); }); // stop "early" when your module is ready
``` ```
This will output the total loading time in milliseconds, giving you a precise measure of the startup performance. ## Contribution
### Advanced Features We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
`@push.rocks/early` allows for more advanced use cases, such as measuring multiple segments individually or in parallel. Each `start` can be matched with a corresponding `stop` to measure different parts of your application independently: For further information read the linked docs at the top of this readme.
```typescript ## Legal
early.start('partOne'); > MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
// Load operations for part one... | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
early.stop().then((time: number) => console.log(`Part one loading time: ${time}`));
early.start('partTwo');
// Load operations for part two...
early.stop().then((time: number) => console.log(`Part two loading time: ${time}`));
```
### High Resolution Time Measurement Class
For more granular control or to measure very short operations, `@push.rocks/early` offers a `HrtMeasurement` class for high-resolution time measurements:
```typescript
import { HrtMeasurement } from '@push.rocks/early';
const hrtMeasurement = new HrtMeasurement();
hrtMeasurement.start();
// perform short duration tasks
hrtMeasurement.stop();
console.log(`Operation took ${hrtMeasurement.milliSeconds} milliseconds`);
```
This can be particularly useful for micro-benchmarks or when measuring the performance impact of optimization efforts.
### Conclusion
`@push.rocks/early` is a powerful yet minimalistic tool for measuring startup times and performance in Node.js applications. Its straightforward API, coupled with TypeScript support, makes it an excellent choice for developers looking to optimize their applications or simply understand their loading characteristics better.
By integrating `@push.rocks/early` into your development process, you can gain valuable insights into your application's performance, helping you make informed decisions about optimizations and improvements.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -3,8 +3,8 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": false, "useDefineForClassFields": false,
"target": "ES2022", "target": "ES2022",
"module": "NodeNext", "module": "ES2022",
"moduleResolution": "NodeNext", "moduleResolution": "nodenext",
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true
}, },