From a96161e7862b249c6df705778332540e96e22c14 Mon Sep 17 00:00:00 2001 From: Yusuf Shakeel Date: Thu, 18 May 2023 22:52:30 +0530 Subject: [PATCH 1/3] removed process.hrtime and using Date directly --- src/helpers/performance.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/helpers/performance.ts b/src/helpers/performance.ts index 7c2cc8b..5b3d04f 100644 --- a/src/helpers/performance.ts +++ b/src/helpers/performance.ts @@ -1,27 +1,25 @@ import { PerformanceType } from '../ts-def/performance-type'; -const NS_PER_SEC = 1e9; - export default class Performance { - private startedAt: [number, number] = [0, 0]; - private duration: [number, number] = [0, 0]; + private startedAt = 0; + private endedAt = 0; public startTimer() { - this.startedAt = process.hrtime(); + this.startedAt = new Date().getTime(); } public stopTimer() { - this.duration = process.hrtime(this.startedAt); + this.endedAt = new Date().getTime(); } public stats(): PerformanceType { - const nano = (this.duration)[0] * NS_PER_SEC + (this.duration)[1]; + const milli = this.endedAt - this.startedAt; return { duration: { - nano, - micro: nano / 1e3, - milli: nano / 1e6, - second: nano / 1e9 + nano: milli * 1e6, + micro: milli * 1e3, + milli, + second: milli / 1e3 } }; } From 9c19f90f1726a6462e75090d97e94ba05d51b5d1 Mon Sep 17 00:00:00 2001 From: Yusuf Shakeel Date: Thu, 18 May 2023 22:54:58 +0530 Subject: [PATCH 2/3] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 730a576..dd546d9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Generate coupons. [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/yusufshakeel/couponjs) -[![npm version](https://img.shields.io/badge/npm-0.11.0-blue.svg)](https://www.npmjs.com/package/couponjs) +[![npm version](https://img.shields.io/badge/npm-0.12.0-blue.svg)](https://www.npmjs.com/package/couponjs) [![npm Downloads](https://img.shields.io/npm/dm/couponjs.svg)](https://www.npmjs.com/package/couponjs) ![CouponJS](./resource/couponjs-500x150.png) From 5cb43ad5055e87c8ecc0f2993d6752370276ba0d Mon Sep 17 00:00:00 2001 From: Yusuf Shakeel Date: Thu, 18 May 2023 22:55:03 +0530 Subject: [PATCH 3/3] 0.12.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 70056f7..bd2ba63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "couponjs", - "version": "0.11.0", + "version": "0.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b77d535..fc0e577 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "couponjs", - "version": "0.11.0", + "version": "0.12.0", "description": "Generate coupons.", "main": "lib/esm/index.js", "types": "lib/types/index.d.ts",