Socket
Socket
Sign inDemoInstall

egg-core

Package Overview
Dependencies
128
Maintainers
13
Versions
137
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.0 to 5.3.0

32

lib/utils/timing.js
'use strict';
const { EOL } = require('os');
const assert = require('assert');
const MAP = Symbol('Timing#map');

@@ -8,5 +10,5 @@ const LIST = Symbol('Timing#list');

class Timing {
constructor() {
this._enable = true;
this._start = null;
this[MAP] = new Map();

@@ -20,3 +22,3 @@ this[LIST] = [];

// process start time
this.start('Process Start', Date.now() - Math.floor((process.uptime() * 1000)));
this.start('Process Start', Date.now() - Math.floor(process.uptime() * 1000));
this.end('Process Start');

@@ -37,2 +39,5 @@

start = start || Date.now();
if (this._start === null) {
this._start = start;
}
const item = {

@@ -77,4 +82,27 @@ name,

}
itemToString(timelineEnd, item, times) {
const isEnd = typeof item.duration === 'number';
const duration = isEnd ? item.duration : timelineEnd - item.start;
const offset = item.start - this._start;
const status = `${duration}ms${isEnd ? '' : ' NOT_END'}`;
const timespan = Math.floor((offset * times).toFixed(6));
let timeline = Math.floor((duration * times).toFixed(6));
timeline = timeline > 0 ? timeline : 1; // make sure there is at least one unit
const message = `#${item.index} ${item.name}`;
return ' '.repeat(timespan) + '▇'.repeat(timeline) + ` [${status}] - ${message}`;
}
toString(prefix = 'egg start timeline:', width = 50) {
const timelineEnd = Date.now();
const timelineDuration = timelineEnd - this._start;
let times = 1;
if (timelineDuration > width) {
times = width / timelineDuration;
}
// follow https://github.com/node-modules/time-profile/blob/master/lib/profiler.js#L88
return prefix + EOL + this[LIST].map(item => this.itemToString(timelineEnd, item, times)).join(EOL);
}
}
module.exports = Timing;

5

package.json
{
"name": "egg-core",
"version": "5.2.0",
"version": "5.3.0",
"description": "A core Pluggable framework based on koa",

@@ -16,2 +16,3 @@ "main": "index.js",

"test-local": "egg-bin test -p",
"test-single": "egg-bin test",
"cov": "egg-bin cov -p",

@@ -62,3 +63,3 @@ "ci": "npm run lint && npm run cov",

"depd": "^2.0.0",
"egg-logger": "^2.4.1",
"egg-logger": "^3.1.0",
"egg-path-matching": "^1.0.1",

@@ -65,0 +66,0 @@ "extend2": "^1.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc