From eb65b8fedf2ac2e64755ca4a1beaeedc949358e4 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 13:35:03 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 14 +++-- package.json | 11 ++-- readme.hints.md | 1 + readme.md | 135 +++++++++++++++++++++++++++++++++++------------- 4 files changed, 120 insertions(+), 41 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 38015f9..a107c78 100644 --- a/npmextra.json +++ b/npmextra.json @@ -9,12 +9,20 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "early", - "description": "minimal and fast loading plugin for startup time measuring", + "description": "A plugin for measuring startup time with minimal performance impact.", "npmPackagename": "@push.rocks/early", - "license": "MIT" + "license": "MIT", + "keywords": [ + "performance measurement", + "startup time", + "high resolution timer", + "plugin", + "typescript", + "nodejs" + ] } }, - "tsdocs": { + "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" } } \ No newline at end of file diff --git a/package.json b/package.json index 44e3355..e6d97ed 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/early", "version": "4.0.4", "private": false, - "description": "minimal and fast loading plugin for startup time measuring", + "description": "A plugin for measuring startup time with minimal performance impact.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -16,7 +16,12 @@ "url": "git+https://gitlab.com/pushrocks/early.git" }, "keywords": [ - "preloader" + "performance measurement", + "startup time", + "high resolution timer", + "plugin", + "typescript", + "nodejs" ], "author": "Lossless GmbH", "license": "MIT", @@ -51,4 +56,4 @@ "browserslist": [ "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index a07795b..c0145c1 100644 --- a/readme.md +++ b/readme.md @@ -1,49 +1,114 @@ # @push.rocks/early minimal and fast loading plugin for startup time measuring -## 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/) +## Install -## Status for master +To install `@push.rocks/early`, run the following command in your terminal: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/early/badges/master/pipeline.svg)](https://lossless.cloud) -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) +```bash +npm install @push.rocks/early --save +``` +This will add `@push.rocks/early` to your project's dependencies and prepare it for use. ## Usage -Use TypeScript for best in class instellisense. +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. -```javascript -// Put the following at the start of your module -import * as early from 'early'; -early.start('myModuleName'); -/* -do your loading stuff -*/ -early.stop().then((loadingTime: number) => { - // loadingTime in milliseconds -}); // stop "early" when your module is ready +### Getting Started with `@push.rocks/early` + +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. + +#### Importing `@push.rocks/early` + +To begin, import the library into your module: + +```typescript +import * as early from '@push.rocks/early'; ``` -## Contribution +#### Starting Measurement -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). :) +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: -For further information read the linked docs at the top of this readme. +```typescript +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. -## Legal -> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +#### 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) => { + console.log(`Loading time: ${loadingTime} milliseconds`); +}); +``` + +This will output the total loading time in milliseconds, giving you a precise measure of the startup performance. + +### Advanced Features + +`@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: + +```typescript +early.start('partOne'); +// Load operations for part one... +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.