Skip to content

Commit

Permalink
perf: measure performance of async oras when in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Jun 27, 2018
1 parent 816d59e commit 3b625de
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"ora": "^2.0.0",
"parse-author": "^2.0.0",
"pify": "^3.0.0",
"pretty-ms": "^3.2.0",
"resolve-package": "^1.0.1",
"s3": "^4.4.0",
"semver": "^5.3.0",
Expand Down Expand Up @@ -114,6 +115,7 @@
"@types/opn": "^5.1.0",
"@types/ora": "^1.3.4",
"@types/pify": "^3.0.1",
"@types/pretty-ms": "^3.0.0",
"@types/proxyquire": "^1.3.28",
"@types/semver": "^5.5.0",
"@types/sinon": "^4.3.1",
Expand Down
6 changes: 4 additions & 2 deletions packages/utils/async-ora/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "mocha --require ts-node/register test/**/*_spec.ts test/**/**/*_spec.ts --opts ../../../mocha.opts"
},
"devDependencies": {
"@types/pretty-ms": "^3.0.0",
"chai": "^4.0.0",
"mocha": "^5.0.0",
"proxyquire": "^2.0.1",
Expand All @@ -20,9 +21,10 @@
"colors": "^1.2.0",
"debug": "^3.0.0",
"log-symbols": "^2.0.0",
"ora": "^2.0.0"
"ora": "^2.0.0",
"pretty-ms": "^3.2.0"
},
"engines": {
"node": ">= 6.0"
}
}
}
15 changes: 11 additions & 4 deletions packages/utils/async-ora/src/ora.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import debug from 'debug';
import logSymbols from 'log-symbols';
import realOra from 'ora';
import { OraImpl } from './ora-handler';
import prettyMs from 'pretty-ms';

const d = debug('electron-forge:async-ora');

Expand All @@ -14,25 +15,31 @@ if (useFakeOra) {

export const fakeOra = (name: string) => {
let oraName = name;
let startTime: number | null = null;
const timing = () => {
if (!startTime) return;
return `-- after ${`${prettyMs(Date.now() - startTime)}`.cyan}`;
};
const fake: OraImpl = {
start: () => {
startTime = Date.now();
d('Process Started:', fake.text);
return fake;
},
fail: () => {
d(`Process Failed: ${fake.text}`.red);
d(`Process Failed: ${fake.text}`.red, timing);
return fake;
},
succeed: () => {
d('Process Succeeded:', fake.text);
d('Process Succeeded:', fake.text, timing());
return fake;
},
stop: () => {
d('Process Stopped:', fake.text);
d('Process Stopped:', fake.text, timing());
return fake;
},
warn: (warning: string) => {
d('Process Warned:', warning);
d('Process Warned:', warning, timing());
return fake;
},
get text() {
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,10 @@
version "3.0.1"
resolved "https://registry.yarnpkg.com/@types/pify/-/pify-3.0.1.tgz#6c45127d0279a9518b0ef48971ec95b91dcb5f47"

"@types/pretty-ms@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/pretty-ms/-/pretty-ms-3.0.0.tgz#c44af8efa730ac2297e3b57dbe7e4d4aeb61d7e4"

"@types/proxyquire@^1.3.28":
version "1.3.28"
resolved "https://registry.yarnpkg.com/@types/proxyquire/-/proxyquire-1.3.28.tgz#05a647bb0d8fe48fc8edcc193e43cc79310faa7d"
Expand Down Expand Up @@ -6572,6 +6576,10 @@ parse-json@^2.2.0:
dependencies:
error-ex "^1.2.0"

parse-ms@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-1.0.1.tgz#56346d4749d78f23430ca0c713850aef91aa361d"

parse-passwd@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6"
Expand Down Expand Up @@ -6764,7 +6772,13 @@ pretty-error@^2.0.2:
renderkid "^2.0.1"
utila "~0.4"

private@^0.1.6:
pretty-ms@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-3.2.0.tgz#87a8feaf27fc18414d75441467d411d6e6098a25"
dependencies:
parse-ms "^1.0.0"

private@^0.1.6, private@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"

Expand Down

0 comments on commit 3b625de

Please sign in to comment.