ic-mops 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Mops CLI Changelog
2
2
 
3
+ ## 1.5.0
4
+ - Compile benchmarks with `--release` flag by default
5
+ - Respect `profile` field in `dfx.json` for benchmarks
6
+
3
7
  ## 1.4.0
4
8
  - Update `mops bench` command output:
5
9
  - Print only final results if benchmarks run in a CI environment or there is no vertical space to progressively print the results
package/bundle/cli.tgz CHANGED
Binary file
package/commands/bench.ts CHANGED
@@ -12,7 +12,7 @@ import {filesize} from 'filesize';
12
12
  import terminalSize from 'terminal-size';
13
13
  import {SemVer} from 'semver';
14
14
 
15
- import {getRootDir, readConfig} from '../mops.js';
15
+ import {getRootDir, readConfig, readDfxJson} from '../mops.js';
16
16
  import {parallel} from '../parallel.js';
17
17
  import {absToRel} from './test/utils.js';
18
18
  import {getMocVersion} from '../helpers/get-moc-version.js';
@@ -49,11 +49,12 @@ type BenchOptions = {
49
49
  compare : boolean,
50
50
  verbose : boolean,
51
51
  silent : boolean,
52
-
52
+ profile : 'Debug' | 'Release',
53
53
  };
54
54
 
55
55
  export async function bench(filter = '', optionsArg : Partial<BenchOptions> = {}) : Promise<Benchmarks> {
56
56
  let config = readConfig();
57
+ let dfxJson = readDfxJson();
57
58
 
58
59
  let defaultOptions : BenchOptions = {
59
60
  replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
@@ -66,6 +67,7 @@ export async function bench(filter = '', optionsArg : Partial<BenchOptions> = {}
66
67
  compare: false,
67
68
  verbose: false,
68
69
  silent: false,
70
+ profile: dfxJson.profile || 'Release',
69
71
  };
70
72
 
71
73
  let options : BenchOptions = {...defaultOptions, ...optionsArg};
@@ -183,12 +185,22 @@ export async function bench(filter = '', optionsArg : Partial<BenchOptions> = {}
183
185
 
184
186
  function getMocArgs(options : BenchOptions) : string {
185
187
  let args = '';
188
+
186
189
  if (options.forceGc) {
187
190
  args += ' --force-gc';
188
191
  }
192
+
189
193
  if (options.gc) {
190
194
  args += ` --${options.gc}-gc`;
191
195
  }
196
+
197
+ if (options.profile === 'Debug') {
198
+ args += ' --debug';
199
+ }
200
+ else if (options.profile === 'Release') {
201
+ args += ' --release';
202
+ }
203
+
192
204
  return args;
193
205
  }
194
206
 
@@ -5,6 +5,7 @@ import {getRootDir} from '../../mops.js';
5
5
  type DfxConfig = {
6
6
  $schema : string;
7
7
  version : number;
8
+ profile : 'Debug' | 'Release';
8
9
  canisters : {
9
10
  [key : string] : {
10
11
  type : 'motoko' | 'assets';
@@ -41,7 +42,7 @@ type DfxConfig = {
41
42
  };
42
43
  };
43
44
 
44
- function readDfxJson() : DfxConfig | Record<string, never> {
45
+ export function readDfxJson() : DfxConfig | Record<string, never> {
45
46
  let dfxJsonPath = path.resolve(getRootDir(), 'dfx.json');
46
47
  if (!existsSync(dfxJsonPath)) {
47
48
  return {};
@@ -11,6 +11,7 @@ type BenchOptions = {
11
11
  compare: boolean;
12
12
  verbose: boolean;
13
13
  silent: boolean;
14
+ profile: 'Debug' | 'Release';
14
15
  };
15
16
  export declare function bench(filter?: string, optionsArg?: Partial<BenchOptions>): Promise<Benchmarks>;
16
17
  export {};
@@ -11,7 +11,7 @@ import stringWidth from 'string-width';
11
11
  import { filesize } from 'filesize';
12
12
  import terminalSize from 'terminal-size';
13
13
  import { SemVer } from 'semver';
14
- import { getRootDir, readConfig } from '../mops.js';
14
+ import { getRootDir, readConfig, readDfxJson } from '../mops.js';
15
15
  import { parallel } from '../parallel.js';
16
16
  import { absToRel } from './test/utils.js';
17
17
  import { getMocVersion } from '../helpers/get-moc-version.js';
@@ -31,6 +31,7 @@ let globConfig = {
31
31
  };
32
32
  export async function bench(filter = '', optionsArg = {}) {
33
33
  let config = readConfig();
34
+ let dfxJson = readDfxJson();
34
35
  let defaultOptions = {
35
36
  replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
36
37
  replicaVersion: '',
@@ -42,6 +43,7 @@ export async function bench(filter = '', optionsArg = {}) {
42
43
  compare: false,
43
44
  verbose: false,
44
45
  silent: false,
46
+ profile: dfxJson.profile || 'Release',
45
47
  };
46
48
  let options = { ...defaultOptions, ...optionsArg };
47
49
  let replicaType = options.replica ?? (config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx');
@@ -145,6 +147,12 @@ function getMocArgs(options) {
145
147
  if (options.gc) {
146
148
  args += ` --${options.gc}-gc`;
147
149
  }
150
+ if (options.profile === 'Debug') {
151
+ args += ' --debug';
152
+ }
153
+ else if (options.profile === 'Release') {
154
+ args += ' --release';
155
+ }
148
156
  return args;
149
157
  }
150
158
  async function deployBenchFile(file, options, replica) {
@@ -1,2 +1,43 @@
1
+ type DfxConfig = {
2
+ $schema: string;
3
+ version: number;
4
+ profile: 'Debug' | 'Release';
5
+ canisters: {
6
+ [key: string]: {
7
+ type: 'motoko' | 'assets';
8
+ main?: string;
9
+ specified_id?: string;
10
+ declarations?: {
11
+ output: string;
12
+ node_compatibility: boolean;
13
+ };
14
+ build?: string[];
15
+ frontend?: {
16
+ entrypoint: string;
17
+ };
18
+ source?: string[];
19
+ remote?: {
20
+ id: {
21
+ ic: string;
22
+ staging: string;
23
+ };
24
+ };
25
+ };
26
+ };
27
+ defaults: {
28
+ build: {
29
+ packtool: string;
30
+ };
31
+ };
32
+ dfx: string;
33
+ networks: {
34
+ [key: string]: {
35
+ type: string;
36
+ providers: string[];
37
+ };
38
+ };
39
+ };
40
+ export declare function readDfxJson(): DfxConfig | Record<string, never>;
1
41
  export declare function getMotokoCanisters(): Record<string, string>;
2
42
  export declare function getMotokoCanistersWithDeclarations(): Record<string, string>;
43
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { getRootDir } from '../../mops.js';
4
- function readDfxJson() {
4
+ export function readDfxJson() {
5
5
  let dfxJsonPath = path.resolve(getRootDir(), 'dfx.json');
6
6
  if (!existsSync(dfxJsonPath)) {
7
7
  return {};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "bin/mops.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/bin/mops.js",