ic-mops 0.45.4-pre.0 → 1.0.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 +19 -1
- package/README.md +1 -1
- package/api/actors.ts +1 -1
- package/bundle/cli.tgz +0 -0
- package/cache.ts +15 -10
- package/cli.ts +27 -27
- package/commands/add.ts +4 -0
- package/commands/bench/bench-canister.mo +34 -8
- package/commands/bench-replica.ts +11 -6
- package/commands/bench.ts +29 -3
- package/commands/publish.ts +1 -1
- package/commands/replica.ts +239 -0
- package/commands/sources.ts +2 -3
- package/commands/test/mmf1.ts +10 -6
- package/commands/test/reporters/compact-reporter.ts +2 -1
- package/commands/test/reporters/files-reporter.ts +3 -2
- package/commands/test/reporters/reporter.ts +2 -1
- package/commands/test/reporters/silent-reporter.ts +2 -1
- package/commands/test/reporters/verbose-reporter.ts +14 -4
- package/commands/test/test.ts +214 -81
- package/commands/user.ts +71 -1
- package/declarations/bench/bench.did +6 -2
- package/declarations/bench/bench.did.d.ts +6 -2
- package/declarations/bench/bench.did.js +6 -2
- package/dist/cache.js +14 -10
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +23 -27
- package/dist/commands/add.js +3 -0
- package/dist/commands/bench/bench-canister.mo +34 -8
- package/dist/commands/bench-replica.d.ts +2 -1
- package/dist/commands/bench-replica.js +10 -6
- package/dist/commands/bench.js +27 -3
- package/dist/commands/publish.js +1 -1
- package/dist/commands/replica.d.ts +59 -0
- package/dist/commands/replica.js +195 -0
- package/dist/commands/sources.d.ts +2 -2
- package/dist/commands/sources.js +2 -3
- package/dist/commands/test/mmf1.d.ts +2 -2
- package/dist/commands/test/mmf1.js +9 -5
- package/dist/commands/test/reporters/compact-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/compact-reporter.js +1 -1
- package/dist/commands/test/reporters/files-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/files-reporter.js +2 -2
- package/dist/commands/test/reporters/reporter.d.ts +2 -1
- package/dist/commands/test/reporters/silent-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/silent-reporter.js +1 -1
- package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -1
- package/dist/commands/test/reporters/verbose-reporter.js +12 -4
- package/dist/commands/test/test.d.ts +10 -8
- package/dist/commands/test/test.js +171 -78
- package/dist/commands/user.d.ts +6 -0
- package/dist/commands/user.js +59 -1
- package/dist/declarations/bench/bench.did +6 -2
- package/dist/declarations/bench/bench.did.d.ts +6 -2
- package/dist/declarations/bench/bench.did.js +6 -2
- package/dist/mops.d.ts +1 -1
- package/dist/mops.js +5 -29
- package/dist/package.json +20 -21
- package/dist/release-cli.js +5 -2
- package/dist/resolve-packages.d.ts +2 -2
- package/dist/resolve-packages.js +29 -7
- package/dist/types.d.ts +1 -0
- package/dist/vessel.js +1 -1
- package/mops.ts +5 -32
- package/package.json +24 -24
- package/release-cli.ts +7 -2
- package/resolve-packages.ts +39 -8
- package/types.ts +3 -1
- package/vessel.ts +1 -1
- package/DEVELOPMENT.md +0 -25
- package/commands/import-identity.ts +0 -62
- package/commands/whoami.ts +0 -12
- package/dist/commands/import-identity.d.ts +0 -5
- package/dist/commands/import-identity.js +0 -51
- package/dist/commands/whoami.d.ts +0 -1
- package/dist/commands/whoami.js +0 -11
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { Command, Argument, Option } from 'commander';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
4
|
import { init } from './commands/init.js';
|
|
6
5
|
import { publish } from './commands/publish.js';
|
|
7
|
-
import { importPem } from './commands/import-identity.js';
|
|
8
6
|
import { sources } from './commands/sources.js';
|
|
9
7
|
import { checkApiCompatibility, setNetwork, apiVersion, checkConfigFile, getNetworkFile, version } from './mops.js';
|
|
10
8
|
import { getNetwork } from './api/network.js';
|
|
11
|
-
import { whoami } from './commands/whoami.js';
|
|
12
9
|
import { installAll } from './commands/install/install-all.js';
|
|
13
10
|
import { search } from './commands/search.js';
|
|
14
11
|
import { add } from './commands/add.js';
|
|
@@ -16,7 +13,7 @@ import { cacheSize, cleanCache, show } from './cache.js';
|
|
|
16
13
|
import { test } from './commands/test/test.js';
|
|
17
14
|
import { template } from './commands/template.js';
|
|
18
15
|
import { remove } from './commands/remove.js';
|
|
19
|
-
import { getUserProp, setUserProp } from './commands/user.js';
|
|
16
|
+
import { importPem, getPrincipal, getUserProp, setUserProp } from './commands/user.js';
|
|
20
17
|
import { bump } from './commands/bump.js';
|
|
21
18
|
import { sync } from './commands/sync.js';
|
|
22
19
|
import { outdated } from './commands/outdated.js';
|
|
@@ -25,6 +22,7 @@ import { bench } from './commands/bench.js';
|
|
|
25
22
|
import { transferOwnership } from './commands/transfer-ownership.js';
|
|
26
23
|
import { toolchain } from './commands/toolchain/index.js';
|
|
27
24
|
import * as self from './commands/self.js';
|
|
25
|
+
import { resolvePackages } from './resolve-packages.js';
|
|
28
26
|
let networkFile = getNetworkFile();
|
|
29
27
|
if (fs.existsSync(networkFile)) {
|
|
30
28
|
globalThis.MOPS_NETWORK = fs.readFileSync(networkFile).toString() || 'ic';
|
|
@@ -71,12 +69,12 @@ program
|
|
|
71
69
|
});
|
|
72
70
|
// install
|
|
73
71
|
program
|
|
74
|
-
.command('install
|
|
72
|
+
.command('install')
|
|
75
73
|
.alias('i')
|
|
76
74
|
.description('Install all dependencies specified in mops.toml')
|
|
77
75
|
.option('--verbose')
|
|
78
76
|
.addOption(new Option('--lock <action>', 'Lockfile action').choices(['check', 'update', 'ignore']))
|
|
79
|
-
.action(async (
|
|
77
|
+
.action(async (options) => {
|
|
80
78
|
if (!checkConfigFile()) {
|
|
81
79
|
process.exit(1);
|
|
82
80
|
}
|
|
@@ -85,17 +83,12 @@ program
|
|
|
85
83
|
return;
|
|
86
84
|
}
|
|
87
85
|
await toolchain.ensureToolchainInited({ strict: false });
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let ok = await installAll(options);
|
|
95
|
-
await toolchain.installAll(options);
|
|
96
|
-
if (!ok) {
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
86
|
+
let ok = await installAll(options);
|
|
87
|
+
await toolchain.installAll(options);
|
|
88
|
+
// check conflicts
|
|
89
|
+
await resolvePackages({ conflicts: 'warning' });
|
|
90
|
+
if (!ok) {
|
|
91
|
+
process.exit(1);
|
|
99
92
|
}
|
|
100
93
|
});
|
|
101
94
|
// publish
|
|
@@ -132,21 +125,21 @@ program
|
|
|
132
125
|
.action(async () => {
|
|
133
126
|
console.log(getNetwork());
|
|
134
127
|
});
|
|
135
|
-
// import
|
|
128
|
+
// user import
|
|
136
129
|
program
|
|
137
|
-
.command('import
|
|
130
|
+
.command('mops user import <data>')
|
|
138
131
|
.description('Import .pem file data to use as identity')
|
|
139
132
|
.addOption(new Option('--no-encrypt', 'Do not ask for a password to encrypt identity'))
|
|
140
133
|
.action(async (data, options) => {
|
|
141
134
|
await importPem(data, options);
|
|
142
|
-
await
|
|
135
|
+
await getPrincipal();
|
|
143
136
|
});
|
|
144
137
|
// sources
|
|
145
138
|
program
|
|
146
139
|
.command('sources')
|
|
147
140
|
.description('for dfx packtool')
|
|
148
141
|
.option('--no-install', 'Do not install dependencies before running sources')
|
|
149
|
-
.
|
|
142
|
+
.addOption(new Option('--conflicts <action>', 'What to do with dependency version conflicts').choices(['ignore', 'warning', 'error']).default('warning'))
|
|
150
143
|
.action(async (options) => {
|
|
151
144
|
if (!checkConfigFile()) {
|
|
152
145
|
process.exit(1);
|
|
@@ -158,12 +151,12 @@ program
|
|
|
158
151
|
let sourcesArr = await sources(options);
|
|
159
152
|
console.log(sourcesArr.join('\n'));
|
|
160
153
|
});
|
|
161
|
-
//
|
|
154
|
+
// get-principal
|
|
162
155
|
program
|
|
163
|
-
.command('
|
|
156
|
+
.command('get-principal')
|
|
164
157
|
.description('Print your principal')
|
|
165
158
|
.action(async () => {
|
|
166
|
-
await
|
|
159
|
+
await getPrincipal();
|
|
167
160
|
});
|
|
168
161
|
// search
|
|
169
162
|
program
|
|
@@ -194,10 +187,12 @@ program
|
|
|
194
187
|
program
|
|
195
188
|
.command('test [filter]')
|
|
196
189
|
.description('Run tests')
|
|
197
|
-
.addOption(new Option('-r, --reporter <reporter>', 'Test reporter').choices(['verbose', 'compact', 'files', 'silent'])
|
|
198
|
-
.addOption(new Option('--mode <mode>', 'Test mode').choices(['interpreter', 'wasi']).default('interpreter'))
|
|
190
|
+
.addOption(new Option('-r, --reporter <reporter>', 'Test reporter').choices(['verbose', 'compact', 'files', 'silent']))
|
|
191
|
+
.addOption(new Option('--mode <mode>', 'Test mode').choices(['interpreter', 'wasi', 'replica']).default('interpreter'))
|
|
192
|
+
.addOption(new Option('--replica <replica>', 'Which replica to use to run tests in replica mode').choices(['dfx', 'pocket-ic']))
|
|
199
193
|
.option('-w, --watch', 'Enable watch mode')
|
|
200
194
|
.action(async (filter, options) => {
|
|
195
|
+
checkConfigFile(true);
|
|
201
196
|
await installAll({ silent: true, lock: 'ignore' });
|
|
202
197
|
await test(filter, options);
|
|
203
198
|
});
|
|
@@ -205,13 +200,14 @@ program
|
|
|
205
200
|
program
|
|
206
201
|
.command('bench [filter]')
|
|
207
202
|
.description('Run benchmarks')
|
|
208
|
-
.addOption(new Option('--replica <replica>', 'Which replica to use to run benchmarks').choices(['dfx', 'pocket-ic'])
|
|
203
|
+
.addOption(new Option('--replica <replica>', 'Which replica to use to run benchmarks').choices(['dfx', 'pocket-ic']))
|
|
209
204
|
.addOption(new Option('--gc <gc>', 'Garbage collector').choices(['copying', 'compacting', 'generational', 'incremental']).default('copying'))
|
|
210
205
|
.addOption(new Option('--save', 'Save benchmark results to .bench/<filename>.json'))
|
|
211
206
|
.addOption(new Option('--compare', 'Run benchmark and compare results with .bench/<filename>.json'))
|
|
212
207
|
// .addOption(new Option('--force-gc', 'Force GC'))
|
|
213
208
|
.addOption(new Option('--verbose', 'Show more information'))
|
|
214
209
|
.action(async (filter, options) => {
|
|
210
|
+
checkConfigFile(true);
|
|
215
211
|
await installAll({ silent: true, lock: 'ignore' });
|
|
216
212
|
await bench(filter, options);
|
|
217
213
|
});
|
package/dist/commands/add.js
CHANGED
|
@@ -10,6 +10,7 @@ import { checkIntegrity } from '../integrity.js';
|
|
|
10
10
|
import { checkRequirements } from '../check-requirements.js';
|
|
11
11
|
import { syncLocalCache } from './install/sync-local-cache.js';
|
|
12
12
|
import { notifyInstalls } from '../notify-installs.js';
|
|
13
|
+
import { resolvePackages } from '../resolve-packages.js';
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
15
|
export async function add(name, { verbose = false, dev = false, lock } = {}, asName) {
|
|
15
16
|
if (!checkConfigFile()) {
|
|
@@ -104,4 +105,6 @@ export async function add(name, { verbose = false, dev = false, lock } = {}, asN
|
|
|
104
105
|
logUpdate.clear();
|
|
105
106
|
await checkRequirements({ verbose });
|
|
106
107
|
console.log(chalk.green('Package installed ') + `${pkgDetails.name} = "${pkgDetails.repo || pkgDetails.path || pkgDetails.version}"`);
|
|
108
|
+
// check conflicts
|
|
109
|
+
await resolvePackages({ conflicts: 'warning' });
|
|
107
110
|
}
|
|
@@ -2,17 +2,35 @@ import Nat64 "mo:base/Nat64";
|
|
|
2
2
|
import Nat "mo:base/Nat";
|
|
3
3
|
import Debug "mo:base/Debug";
|
|
4
4
|
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
5
|
+
import ExperimentalStableMemory "mo:base/ExperimentalStableMemory";
|
|
6
|
+
import Int64 "mo:base/Int64";
|
|
7
|
+
import Region "mo:base/Region";
|
|
5
8
|
import Prim "mo:prim";
|
|
6
9
|
import Bench "mo:bench";
|
|
7
10
|
|
|
8
11
|
import UserBench "./user-bench"; // file path will be replaced with the *.bench.mo file path
|
|
9
12
|
|
|
10
13
|
actor class() {
|
|
14
|
+
type BenchResult = {
|
|
15
|
+
instructions : Int;
|
|
16
|
+
rts_mutator_instructions : Int;
|
|
17
|
+
stable_memory_size : Int;
|
|
18
|
+
rts_stable_memory_size : Int;
|
|
19
|
+
rts_logical_stable_memory_size : Int;
|
|
20
|
+
rts_collector_instructions : Int;
|
|
21
|
+
rts_heap_size : Int;
|
|
22
|
+
rts_memory_size : Int;
|
|
23
|
+
rts_total_allocation : Int;
|
|
24
|
+
rts_reclaimed : Int;
|
|
25
|
+
};
|
|
26
|
+
|
|
11
27
|
var benchOpt : ?Bench.Bench = null;
|
|
12
28
|
|
|
13
29
|
public func init() : async Bench.BenchSchema {
|
|
14
30
|
let bench = UserBench.init();
|
|
15
31
|
benchOpt := ?bench;
|
|
32
|
+
// ignore ExperimentalStableMemory.grow(1);
|
|
33
|
+
ignore Region.grow(Region.new(), 1);
|
|
16
34
|
bench.getSchema();
|
|
17
35
|
};
|
|
18
36
|
|
|
@@ -21,29 +39,37 @@ actor class() {
|
|
|
21
39
|
bench.getSchema();
|
|
22
40
|
};
|
|
23
41
|
|
|
24
|
-
func _getStats() :
|
|
42
|
+
func _getStats() : BenchResult {
|
|
25
43
|
{
|
|
26
44
|
instructions = 0;
|
|
27
45
|
rts_heap_size = Prim.rts_heap_size();
|
|
46
|
+
stable_memory_size = Int64.toInt(Int64.fromNat64(ExperimentalStableMemory.size())) * 65536;
|
|
47
|
+
rts_stable_memory_size = Prim.rts_stable_memory_size();
|
|
48
|
+
rts_logical_stable_memory_size = Prim.rts_logical_stable_memory_size();
|
|
28
49
|
rts_memory_size = Prim.rts_memory_size();
|
|
29
50
|
rts_total_allocation = Prim.rts_total_allocation();
|
|
51
|
+
rts_reclaimed = Prim.rts_reclaimed();
|
|
30
52
|
rts_mutator_instructions = Prim.rts_mutator_instructions();
|
|
31
53
|
rts_collector_instructions = Prim.rts_collector_instructions();
|
|
32
54
|
}
|
|
33
55
|
};
|
|
34
56
|
|
|
35
|
-
func _diffStats(before :
|
|
57
|
+
func _diffStats(before : BenchResult, after : BenchResult) : BenchResult {
|
|
36
58
|
{
|
|
37
59
|
instructions = after.instructions - before.instructions;
|
|
38
60
|
rts_heap_size = after.rts_heap_size - before.rts_heap_size;
|
|
61
|
+
stable_memory_size = after.stable_memory_size - before.stable_memory_size;
|
|
62
|
+
rts_stable_memory_size = after.rts_stable_memory_size - before.rts_stable_memory_size;
|
|
63
|
+
rts_logical_stable_memory_size = after.rts_logical_stable_memory_size - before.rts_logical_stable_memory_size;
|
|
39
64
|
rts_memory_size = after.rts_memory_size - before.rts_memory_size;
|
|
40
65
|
rts_total_allocation = after.rts_total_allocation - before.rts_total_allocation;
|
|
66
|
+
rts_reclaimed = after.rts_reclaimed - before.rts_reclaimed;
|
|
41
67
|
rts_mutator_instructions = after.rts_mutator_instructions - before.rts_mutator_instructions;
|
|
42
68
|
rts_collector_instructions = after.rts_collector_instructions - before.rts_collector_instructions;
|
|
43
69
|
}
|
|
44
70
|
};
|
|
45
71
|
|
|
46
|
-
func _runCell(rowIndex : Nat, colIndex : Nat) :
|
|
72
|
+
func _runCell(rowIndex : Nat, colIndex : Nat) : BenchResult {
|
|
47
73
|
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
48
74
|
let statsBefore = _getStats();
|
|
49
75
|
|
|
@@ -55,7 +81,7 @@ actor class() {
|
|
|
55
81
|
_diffStats(statsBefore, { statsAfter with instructions });
|
|
56
82
|
};
|
|
57
83
|
|
|
58
|
-
func _runCellAwait(rowIndex : Nat, colIndex : Nat) : async
|
|
84
|
+
func _runCellAwait(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
59
85
|
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
60
86
|
let statsBefore = _getStats();
|
|
61
87
|
|
|
@@ -69,19 +95,19 @@ actor class() {
|
|
|
69
95
|
_diffStats(statsBefore, { statsAfter with instructions });
|
|
70
96
|
};
|
|
71
97
|
|
|
72
|
-
public query func getStats() : async
|
|
98
|
+
public query func getStats() : async BenchResult {
|
|
73
99
|
_getStats();
|
|
74
100
|
};
|
|
75
101
|
|
|
76
|
-
public query func runCellQuery(rowIndex : Nat, colIndex : Nat) : async
|
|
102
|
+
public query func runCellQuery(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
77
103
|
_runCell(rowIndex, colIndex);
|
|
78
104
|
};
|
|
79
105
|
|
|
80
|
-
public func runCellUpdate(rowIndex : Nat, colIndex : Nat) : async
|
|
106
|
+
public func runCellUpdate(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
81
107
|
_runCell(rowIndex, colIndex);
|
|
82
108
|
};
|
|
83
109
|
|
|
84
|
-
public func runCellUpdateAwait(rowIndex : Nat, colIndex : Nat) : async
|
|
110
|
+
public func runCellUpdateAwait(rowIndex : Nat, colIndex : Nat) : async BenchResult {
|
|
85
111
|
await _runCellAwait(rowIndex, colIndex);
|
|
86
112
|
};
|
|
87
113
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PocketIc } from 'pic-ic';
|
|
1
|
+
import { PocketIc, PocketIcServer } from 'pic-ic';
|
|
2
2
|
export declare class BenchReplica {
|
|
3
3
|
type: 'dfx' | 'pocket-ic';
|
|
4
4
|
verbose: boolean;
|
|
@@ -7,6 +7,7 @@ export declare class BenchReplica {
|
|
|
7
7
|
canisterId: string;
|
|
8
8
|
actor: any;
|
|
9
9
|
}>;
|
|
10
|
+
pocketIcServer?: PocketIcServer;
|
|
10
11
|
pocketIc?: PocketIc;
|
|
11
12
|
constructor(type: 'dfx' | 'pocket-ic', verbose?: boolean);
|
|
12
13
|
start({ silent }?: {
|
|
@@ -3,7 +3,7 @@ import { execSync } from 'node:child_process';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import { execaCommand } from 'execa';
|
|
6
|
-
import { PocketIc } from 'pic-ic';
|
|
6
|
+
import { PocketIc, PocketIcServer } from 'pic-ic';
|
|
7
7
|
import { getRootDir, readConfig } from '../mops.js';
|
|
8
8
|
import { createActor, idlFactory } from '../declarations/bench/index.js';
|
|
9
9
|
import { toolchain } from './toolchain/index.js';
|
|
@@ -25,11 +25,14 @@ export class BenchReplica {
|
|
|
25
25
|
else {
|
|
26
26
|
let pocketIcBin = await toolchain.bin('pocket-ic');
|
|
27
27
|
let config = readConfig();
|
|
28
|
-
if (config.toolchain?.['pocket-ic'] !== '
|
|
29
|
-
console.error('
|
|
28
|
+
if (config.toolchain?.['pocket-ic'] !== '4.0.0') {
|
|
29
|
+
console.error('Current Mops CLI only supports pocket-ic 4.0.0');
|
|
30
30
|
process.exit(1);
|
|
31
31
|
}
|
|
32
|
-
this.
|
|
32
|
+
this.pocketIcServer = await PocketIcServer.start({
|
|
33
|
+
binPath: pocketIcBin,
|
|
34
|
+
});
|
|
35
|
+
this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
async stop() {
|
|
@@ -37,8 +40,9 @@ export class BenchReplica {
|
|
|
37
40
|
let dir = path.join(getRootDir(), '.mops/.bench');
|
|
38
41
|
execSync('dfx stop' + (this.verbose ? '' : ' -qqqq'), { cwd: dir, stdio: ['pipe', this.verbose ? 'inherit' : 'ignore', 'pipe'] });
|
|
39
42
|
}
|
|
40
|
-
else if (this.pocketIc) {
|
|
43
|
+
else if (this.pocketIc && this.pocketIcServer) {
|
|
41
44
|
await this.pocketIc.tearDown();
|
|
45
|
+
await this.pocketIcServer.stop();
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
async deploy(name, wasm, cwd = process.cwd()) {
|
|
@@ -53,7 +57,7 @@ export class BenchReplica {
|
|
|
53
57
|
this.canisters[name] = { cwd, canisterId, actor };
|
|
54
58
|
}
|
|
55
59
|
else if (this.pocketIc) {
|
|
56
|
-
let { canisterId, actor } = await this.pocketIc.setupCanister(idlFactory, wasm);
|
|
60
|
+
let { canisterId, actor } = await this.pocketIc.setupCanister({ idlFactory, wasm });
|
|
57
61
|
this.canisters[name] = {
|
|
58
62
|
cwd,
|
|
59
63
|
canisterId: canisterId.toText(),
|
package/dist/commands/bench.js
CHANGED
|
@@ -16,6 +16,7 @@ import { getDfxVersion } from '../helpers/get-dfx-version.js';
|
|
|
16
16
|
import { getMocPath } from '../helpers/get-moc-path.js';
|
|
17
17
|
import { sources } from './sources.js';
|
|
18
18
|
import { BenchReplica } from './bench-replica.js';
|
|
19
|
+
import { filesize } from 'filesize';
|
|
19
20
|
let ignore = [
|
|
20
21
|
'**/node_modules/**',
|
|
21
22
|
'**/.mops/**',
|
|
@@ -27,8 +28,9 @@ let globConfig = {
|
|
|
27
28
|
ignore: ignore,
|
|
28
29
|
};
|
|
29
30
|
export async function bench(filter = '', optionsArg = {}) {
|
|
31
|
+
let config = readConfig();
|
|
30
32
|
let defaultOptions = {
|
|
31
|
-
replica: 'dfx',
|
|
33
|
+
replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
|
|
32
34
|
replicaVersion: '',
|
|
33
35
|
compiler: 'moc',
|
|
34
36
|
compilerVersion: getMocVersion(),
|
|
@@ -44,7 +46,6 @@ export async function bench(filter = '', optionsArg = {}) {
|
|
|
44
46
|
options.replicaVersion = getDfxVersion();
|
|
45
47
|
}
|
|
46
48
|
else if (options.replica == 'pocket-ic') {
|
|
47
|
-
let config = readConfig();
|
|
48
49
|
options.replicaVersion = config.toolchain?.['pocket-ic'] || '';
|
|
49
50
|
}
|
|
50
51
|
options.verbose && console.log(options);
|
|
@@ -171,9 +172,14 @@ async function runBenchFile(file, options, replica) {
|
|
|
171
172
|
let results = new Map();
|
|
172
173
|
let instructionsCells = Array.from({ length: schema.rows.length }, () => []);
|
|
173
174
|
let heapCells = Array.from({ length: schema.rows.length }, () => []);
|
|
175
|
+
let logicalStableMemoryCells = Array.from({ length: schema.rows.length }, () => []);
|
|
176
|
+
let reclaimedCells = Array.from({ length: schema.rows.length }, () => []);
|
|
174
177
|
let formatNumber = (n) => {
|
|
175
178
|
return n.toLocaleString('en-US').replaceAll(',', '_');
|
|
176
179
|
};
|
|
180
|
+
let formatSize = (n) => {
|
|
181
|
+
return filesize(n, { standard: 'iec', round: 2 });
|
|
182
|
+
};
|
|
177
183
|
let getTable = (prop) => {
|
|
178
184
|
let resArr = [['', ...schema.cols]];
|
|
179
185
|
for (let [_rowIndex, row] of schema.rows.entries()) {
|
|
@@ -197,7 +203,17 @@ async function runBenchFile(file, options, replica) {
|
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
// add to table
|
|
200
|
-
|
|
206
|
+
let value = '';
|
|
207
|
+
if (prop == 'rts_logical_stable_memory_size') {
|
|
208
|
+
value = formatSize(res[prop] * 65536n);
|
|
209
|
+
}
|
|
210
|
+
else if (prop === 'rts_heap_size' || prop == 'rts_reclaimed') {
|
|
211
|
+
value = formatSize(res[prop]);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
value = formatNumber(res[prop]);
|
|
215
|
+
}
|
|
216
|
+
curRow.push(value + diff);
|
|
201
217
|
}
|
|
202
218
|
else {
|
|
203
219
|
curRow.push('');
|
|
@@ -216,6 +232,8 @@ async function runBenchFile(file, options, replica) {
|
|
|
216
232
|
${schema.description ? '\n' + chalk.gray(schema.description) : ''}
|
|
217
233
|
\n\n${chalk.blue('Instructions')}\n\n${getTable('instructions')}
|
|
218
234
|
\n\n${chalk.blue('Heap')}\n\n${getTable('rts_heap_size')}
|
|
235
|
+
\n\n${chalk.blue('Stable Memory')}\n\n${getTable('rts_logical_stable_memory_size')}
|
|
236
|
+
\n\n${chalk.blue('Garbage Collection')}\n\n${getTable('rts_reclaimed')}
|
|
219
237
|
`);
|
|
220
238
|
};
|
|
221
239
|
if (!process.env.CI && !options.silent) {
|
|
@@ -230,6 +248,10 @@ async function runBenchFile(file, options, replica) {
|
|
|
230
248
|
instructionsCells[rowIndex][colIndex] = res.instructions;
|
|
231
249
|
// @ts-ignore
|
|
232
250
|
heapCells[rowIndex][colIndex] = res.rts_heap_size;
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
logicalStableMemoryCells[rowIndex][colIndex] = res.rts_logical_stable_memory_size;
|
|
253
|
+
// @ts-ignore
|
|
254
|
+
reclaimedCells[rowIndex][colIndex] = res.rts_reclaimed;
|
|
233
255
|
if (!process.env.CI && !options.silent) {
|
|
234
256
|
printResults();
|
|
235
257
|
}
|
|
@@ -277,6 +299,8 @@ async function runBenchFile(file, options, replica) {
|
|
|
277
299
|
metrics: [
|
|
278
300
|
['instructions', instructionsCells],
|
|
279
301
|
['rts_heap_size', heapCells],
|
|
302
|
+
['rts_logical_stable_memory_size', logicalStableMemoryCells],
|
|
303
|
+
['rts_reclaimed', reclaimedCells],
|
|
280
304
|
],
|
|
281
305
|
};
|
|
282
306
|
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -242,7 +242,7 @@ export async function publish(options = {}) {
|
|
|
242
242
|
let reporter = new SilentReporter;
|
|
243
243
|
if (options.test) {
|
|
244
244
|
console.log('Running tests...');
|
|
245
|
-
await testWithReporter(reporter);
|
|
245
|
+
await testWithReporter(reporter, '', 'interpreter', config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx');
|
|
246
246
|
if (reporter.failed > 0) {
|
|
247
247
|
console.log(chalk.red('Error: ') + 'tests failed');
|
|
248
248
|
process.exit(1);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
|
+
import { PassThrough } from 'node:stream';
|
|
3
|
+
import { IDL } from '@dfinity/candid';
|
|
4
|
+
import { PocketIc, PocketIcServer } from 'pic-ic';
|
|
5
|
+
type StartOptions = {
|
|
6
|
+
type?: 'dfx' | 'pocket-ic';
|
|
7
|
+
dir?: string;
|
|
8
|
+
verbose?: boolean;
|
|
9
|
+
silent?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare class Replica {
|
|
12
|
+
type: 'dfx' | 'pocket-ic';
|
|
13
|
+
verbose: boolean;
|
|
14
|
+
canisters: Record<string, {
|
|
15
|
+
cwd: string;
|
|
16
|
+
canisterId: string;
|
|
17
|
+
actor: any;
|
|
18
|
+
stream: PassThrough;
|
|
19
|
+
}>;
|
|
20
|
+
pocketIcServer?: PocketIcServer;
|
|
21
|
+
pocketIc?: PocketIc;
|
|
22
|
+
dfxProcess?: ChildProcessWithoutNullStreams;
|
|
23
|
+
dir: string;
|
|
24
|
+
ttl: number;
|
|
25
|
+
start({ type, dir, verbose, silent }?: StartOptions): Promise<void>;
|
|
26
|
+
_attachCanisterLogHandler(proc: ChildProcessWithoutNullStreams): void;
|
|
27
|
+
stop(sigint?: boolean): Promise<void>;
|
|
28
|
+
deploy(name: string, wasm: string, idlFactory: IDL.InterfaceFactory, cwd?: string): Promise<{
|
|
29
|
+
cwd: string;
|
|
30
|
+
canisterId: string;
|
|
31
|
+
actor: any;
|
|
32
|
+
stream: PassThrough;
|
|
33
|
+
}>;
|
|
34
|
+
getActor(name: string): unknown;
|
|
35
|
+
getCanister(name: string): {
|
|
36
|
+
cwd: string;
|
|
37
|
+
canisterId: string;
|
|
38
|
+
actor: any;
|
|
39
|
+
stream: PassThrough;
|
|
40
|
+
} | undefined;
|
|
41
|
+
getCanisterId(name: string): string;
|
|
42
|
+
getCanisterStream(canisterId: string): PassThrough | null;
|
|
43
|
+
dfxJson(canisterName: string, wasmPath?: string, didPath?: string): {
|
|
44
|
+
version: number;
|
|
45
|
+
canisters: Record<string, any>;
|
|
46
|
+
defaults: {
|
|
47
|
+
build: {
|
|
48
|
+
packtool: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
networks: {
|
|
52
|
+
local: {
|
|
53
|
+
type: string;
|
|
54
|
+
bind: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export {};
|