-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.mjs
90 lines (73 loc) · 2.49 KB
/
config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
///////////////////////////////
// Default benchmark parameters
///////////////////////////////
export let benchmarkIterations = 5
export let processIterations = 10
export let workerPoolSize = 6
export let filesCount = 3000
export let filesChunkSize = 50
export const dataURL = new URL('./shared/data.txt', import.meta.url)
export const processorURL = new URL('./shared/processor.mjs', import.meta.url)
////////////////////////////////////
// Benchmark parameter CLI overrides
////////////////////////////////////
// Deno CLI overrides
if ('Deno' in globalThis) {
const { parse } = await import('https://deno.land/[email protected]/flags/mod.ts')
const cli = parse(Deno.args, {
string: [
'benchmark-iterations',
'process-iterations',
'worker-pool-size',
'files-count',
'files-chunk-size',
],
alias: {
'benchmark-iterations': 'b',
'process-iterations': 'p',
'worker-pool-size': 'w',
'files-count': 'f',
'files-chunk-size': 'c',
},
})
benchmarkIterations = cli['benchmark-iterations']
? Number(cli['benchmark-iterations'])
: benchmarkIterations
processIterations = cli['process-iterations']
? Number(cli['process-iterations'])
: processIterations
workerPoolSize = cli['worker-pool-size']
? Number(cli['worker-pool-size'])
: workerPoolSize
filesCount = cli['files-count'] ? Number(cli['files-count']) : filesCount
filesChunkSize = cli['files-chunk-size']
? Number(cli['files-chunk-size'])
: filesChunkSize
} else {
// Node CLI overrides
const util = await import('node:util')
const cli = util.parseArgs({
options: {
'benchmark-iterations': { short: 'b', type: 'string' },
'process-iterations': { short: 'p', type: 'string' },
'worker-pool-size': { short: 'w', type: 'string' },
'files-count': { short: 'f', type: 'string' },
'files-chunk-size': { short: 'c', type: 'string' },
},
})
benchmarkIterations = cli.values['benchmark-iterations']
? Number(cli.values['benchmark-iterations'])
: benchmarkIterations
processIterations = cli.values['process-iterations']
? Number(cli.values['process-iterations'])
: processIterations
workerPoolSize = cli.values['worker-pool-size']
? Number(cli.values['worker-pool-size'])
: workerPoolSize
filesCount = cli.values['files-count']
? Number(cli.values['files-count'])
: filesCount
filesChunkSize = cli.values['files-chunk-size']
? Number(cli.values['files-chunk-size'])
: filesChunkSize
}