Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 809efa4

Browse files
committed
implemented yargs
1 parent 123b45e commit 809efa4

File tree

3 files changed

+152
-18
lines changed

3 files changed

+152
-18
lines changed

benchmark/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@
4545
"redux": "^4.1.0",
4646
"typescript": "^4.3.5",
4747
"valtio": "^1.0.6",
48+
"yargs": "^17.1.0",
4849
"zustand": "^3.5.5"
4950
},
5051
"devDependencies": {
5152
"@types/benchmark": "^2.1.0",
5253
"@types/node": "^16.0.0",
5354
"@types/react": "^17.0.13",
54-
"@types/react-dom": "^17.0.8"
55+
"@types/react-dom": "^17.0.8",
56+
"@types/yargs": "^17.0.2"
5557
},
5658
"bugs": {
5759
"url": "https://github.com/agile-ts/agile/issues"

benchmark/runtime/run.ts

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,55 @@
11
import dotenv from 'dotenv';
2-
import { startSpeedBench } from './benchmarkTypes';
2+
import { startBundleBench, startSpeedBench } from './benchmarkTypes';
3+
import yargs from 'yargs';
4+
import { hideBin } from 'yargs/helpers';
35

46
// Loads environment variables from the '.env' file
57
dotenv.config();
68

79
// TODO implement yargs https://yargs.js.org/
810

9-
// https://nodejs.org/docs/latest/api/process.html#process_process_argv
10-
// Extract entry (at third parameter) from the executed command
11-
// yarn run ./path/to/entry -> './path/to/entry' is extracted
12-
const entry = process.argv.slice(2)[0];
13-
const isDev =
14-
process.argv.slice(2)[1] === '--dev' || process.env.DEV === 'true';
11+
// hideBind handles the 'process.argv.slice' logic
12+
const argv = yargs(hideBin(process.argv))
13+
.option('_', {
14+
type: 'string',
15+
default: ['./benchmarks/react/counter'],
16+
description: 'What benchmark to execute',
17+
})
18+
.option('dev', {
19+
type: 'boolean',
20+
default: false,
21+
description:
22+
'Whether to start the benchmark/s in developer mode for better debugging.',
23+
})
24+
.option('type', {
25+
type: 'string',
26+
default: 'speed',
27+
description: 'What type of benchmark to be executed',
28+
}).argv;
29+
30+
console.log(argv);
31+
32+
const entry = argv._[0];
33+
const isDev = argv.dev;
34+
const benchmarkType = argv.type;
35+
1536
if (entry == null) {
1637
throw new Error(
1738
"No valid entry was provided! Valid entry example: 'yarn run ./benchmarks/react/counter'"
1839
);
1940
}
2041

21-
// Execute the Benchmark
22-
startSpeedBench(entry, isDev);
42+
// Benchmarks that can be executed marked with a unique identifier
43+
const benchmarks: {
44+
[key: string]: (entry: string, isDev: boolean) => Promise<void>;
45+
} = {
46+
speed: startSpeedBench,
47+
bundle: startBundleBench,
48+
};
49+
50+
// Execute Benchmark based on the specified Benchmark type
51+
const toExecuteBenchmark = benchmarks[benchmarkType];
52+
if (toExecuteBenchmark != null) toExecuteBenchmark(entry, isDev);
53+
else {
54+
benchmarks['speed'](entry, isDev);
55+
}

benchmark/yarn.lock

Lines changed: 107 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44

55
"@agile-ts/core@file:.yalc/@agile-ts/core":
6-
version "0.1.0"
6+
version "0.2.0-alpha.3"
77
dependencies:
8-
"@agile-ts/utils" "^0.0.5"
8+
"@agile-ts/utils" "^0.0.7"
99

1010
"@agile-ts/react@file:.yalc/@agile-ts/react":
11-
version "0.1.0"
11+
version "0.1.2"
1212

13-
"@agile-ts/utils@^0.0.5":
14-
version "0.0.5"
15-
resolved "https://registry.yarnpkg.com/@agile-ts/utils/-/utils-0.0.5.tgz#23cc83e60eb6b15734247fac1d77f1fd629ffdb6"
16-
integrity sha512-R86X9MjMty14eoQ4djulZSdHf9mIF9dPcj4g+SABqdA6AqbewS0/BQGNGR5p6gXhqc4+mT8rzkutywdPnMUNfA==
13+
"@agile-ts/utils@^0.0.7":
14+
version "0.0.7"
15+
resolved "https://registry.yarnpkg.com/@agile-ts/utils/-/utils-0.0.7.tgz#3dd1add6b9f63d0a5bf35e71f54ac46448ae047f"
16+
integrity sha512-OviTDC+ZbfyiUx8Gy8veS6YymC/tT6UeP23nT8V0EQV4F2MmuWqZ2yiKk+AYxZx8h74Ey8BVEUX6/ntpxhSNPw==
1717

1818
"@babel/runtime@^7.12.1", "@babel/runtime@^7.9.2":
1919
version "7.14.6"
@@ -101,6 +101,18 @@
101101
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
102102
integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==
103103

104+
"@types/yargs-parser@*":
105+
version "20.2.1"
106+
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.1.tgz#3b9ce2489919d9e4fea439b76916abc34b2df129"
107+
integrity sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==
108+
109+
"@types/yargs@^17.0.2":
110+
version "17.0.2"
111+
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.2.tgz#8fb2e0f4cdc7ab2a1a570106e56533f31225b584"
112+
integrity sha512-JhZ+pNdKMfB0rXauaDlrIvm+U7V4m03PPOSVoPS66z8gf+G4Z/UW8UlrVIj2MRQOBzuoEvYtjS0bqYwnpZaS9Q==
113+
dependencies:
114+
"@types/yargs-parser" "*"
115+
104116
"@types/yauzl@^2.9.1":
105117
version "2.9.2"
106118
resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.9.2.tgz#c48e5d56aff1444409e39fa164b0b4d4552a7b7a"
@@ -115,7 +127,12 @@ agent-base@6:
115127
dependencies:
116128
debug "4"
117129

118-
ansi-styles@^4.1.0:
130+
ansi-regex@^5.0.0:
131+
version "5.0.0"
132+
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
133+
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
134+
135+
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
119136
version "4.3.0"
120137
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
121138
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
@@ -156,6 +173,15 @@ chalk@^4.1.1:
156173
ansi-styles "^4.1.0"
157174
supports-color "^7.1.0"
158175

176+
cliui@^7.0.2:
177+
version "7.0.4"
178+
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
179+
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
180+
dependencies:
181+
string-width "^4.2.0"
182+
strip-ansi "^6.0.0"
183+
wrap-ansi "^7.0.0"
184+
159185
color-convert@^2.0.1:
160186
version "2.0.1"
161187
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
@@ -200,6 +226,11 @@ dotenv@^10.0.0:
200226
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81"
201227
integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==
202228

229+
emoji-regex@^8.0.0:
230+
version "8.0.0"
231+
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
232+
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
233+
203234
end-of-stream@^1.1.0:
204235
version "1.4.4"
205236
resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0"
@@ -220,6 +251,11 @@ esbuild@^0.12.14, esbuild@^0.12.8:
220251
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.12.14.tgz#43157dbd0b36d939247d4eb4909a4886ac40f82e"
221252
integrity sha512-z8p+6FGiplR7a3pPonXREbm+8IeXjBGvDpVidZmGB/AJMsJSfGCU+n7KOMCazA9AwvagadRWBhiKorC0w9WJvw==
222253

254+
escalade@^3.1.1:
255+
version "3.1.1"
256+
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
257+
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
258+
223259
escape-string-regexp@^2.0.0:
224260
version "2.0.0"
225261
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344"
@@ -248,6 +284,11 @@ fs.realpath@^1.0.0:
248284
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
249285
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
250286

287+
get-caller-file@^2.0.5:
288+
version "2.0.5"
289+
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
290+
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
291+
251292
get-stream@^5.1.0:
252293
version "5.2.0"
253294
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3"
@@ -315,6 +356,11 @@ inherits@2:
315356
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
316357
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
317358

359+
is-fullwidth-code-point@^3.0.0:
360+
version "3.0.0"
361+
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
362+
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
363+
318364
jotai@^1.1.2:
319365
version "1.1.2"
320366
resolved "https://registry.yarnpkg.com/jotai/-/jotai-1.1.2.tgz#3f211e0c03c74e95ea6fd7a69c1d2b65731009bf"
@@ -537,6 +583,11 @@ regenerator-runtime@^0.13.4:
537583
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
538584
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==
539585

586+
require-directory@^2.1.1:
587+
version "2.1.1"
588+
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
589+
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
590+
540591
reselect@^4.0.0:
541592
version "4.0.0"
542593
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.0.0.tgz#f2529830e5d3d0e021408b246a206ef4ea4437f7"
@@ -574,6 +625,22 @@ stack-utils@^2.0.3:
574625
dependencies:
575626
escape-string-regexp "^2.0.0"
576627

628+
string-width@^4.1.0, string-width@^4.2.0:
629+
version "4.2.2"
630+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
631+
integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==
632+
dependencies:
633+
emoji-regex "^8.0.0"
634+
is-fullwidth-code-point "^3.0.0"
635+
strip-ansi "^6.0.0"
636+
637+
strip-ansi@^6.0.0:
638+
version "6.0.0"
639+
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532"
640+
integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==
641+
dependencies:
642+
ansi-regex "^5.0.0"
643+
577644
supports-color@^7.1.0:
578645
version "7.2.0"
579646
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
@@ -593,6 +660,15 @@ valtio@^1.0.6:
593660
dependencies:
594661
proxy-compare "2.0.0"
595662

663+
wrap-ansi@^7.0.0:
664+
version "7.0.0"
665+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
666+
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
667+
dependencies:
668+
ansi-styles "^4.0.0"
669+
string-width "^4.1.0"
670+
strip-ansi "^6.0.0"
671+
596672
wrappy@1:
597673
version "1.0.2"
598674
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
@@ -603,6 +679,29 @@ ws@^7.4.6:
603679
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.1.tgz#44fc000d87edb1d9c53e51fbc69a0ac1f6871d66"
604680
integrity sha512-2c6faOUH/nhoQN6abwMloF7Iyl0ZS2E9HGtsiLrWn0zOOMWlhtDmdf/uihDt6jnuCxgtwGBNy6Onsoy2s2O2Ow==
605681

682+
y18n@^5.0.5:
683+
version "5.0.8"
684+
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
685+
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
686+
687+
yargs-parser@^20.2.2:
688+
version "20.2.9"
689+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
690+
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
691+
692+
yargs@^17.1.0:
693+
version "17.1.0"
694+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.1.0.tgz#0cd9827a0572c9a1795361c4d1530e53ada168cf"
695+
integrity sha512-SQr7qqmQ2sNijjJGHL4u7t8vyDZdZ3Ahkmo4sc1w5xI9TBX0QDdG/g4SFnxtWOsGLjwHQue57eFALfwFCnixgg==
696+
dependencies:
697+
cliui "^7.0.2"
698+
escalade "^3.1.1"
699+
get-caller-file "^2.0.5"
700+
require-directory "^2.1.1"
701+
string-width "^4.2.0"
702+
y18n "^5.0.5"
703+
yargs-parser "^20.2.2"
704+
606705
yauzl@^2.10.0:
607706
version "2.10.0"
608707
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"

0 commit comments

Comments
 (0)