ic-mops 0.31.0 → 0.31.2
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/dist/commands/bench/bench-canister.mo +5 -0
- package/dist/commands/bench.js +29 -16
- package/dist/declarations/bench/bench.did +1 -0
- package/dist/declarations/bench/bench.did.d.ts +1 -0
- package/dist/declarations/bench/bench.did.js +7 -6
- package/dist/package.json +1 -1
- package/dist/resolve-packages.js +1 -1
- package/dist/vessel.d.ts +2 -1
- package/dist/vessel.js +9 -7
- package/package.json +1 -1
- package/resolve-packages.ts +1 -1
- package/vessel.ts +10 -8
- package/dist/bench/$USER_BENCH_FILE.mo +0 -45
- package/dist/bench/bench-canister.mo +0 -57
- package/dist/commands/bench/$USER_BENCH_FILE.mo +0 -45
- package/dist/commands/bench/bench/$USER_BENCH_FILE.mo +0 -45
- package/dist/commands/bench/bench/bench-canister.mo +0 -57
- package/dist/commands/bench/declarations/bench/bench.did.d.ts +0 -6
- package/dist/commands/bench/declarations/bench/bench.did.js +0 -22
- package/dist/commands/bench/declarations/bench/index.d.ts +0 -2
- package/dist/commands/bench/declarations/bench/index.js +0 -30
- package/dist/commands/bench/declarations/main/index.d.ts +0 -2
- package/dist/commands/bench/declarations/main/index.js +0 -30
- package/dist/commands/bench/declarations/main/main.did.d.ts +0 -6
- package/dist/commands/bench/declarations/main/main.did.js +0 -242
- package/dist/commands/bench/declarations/storage/index.d.ts +0 -4
- package/dist/commands/bench/declarations/storage/index.js +0 -26
- package/dist/commands/bench/declarations/storage/storage.did.d.ts +0 -6
- package/dist/commands/bench/declarations/storage/storage.did.js +0 -34
- package/dist/commands/mmf1.d.ts +0 -21
- package/dist/commands/mmf1.js +0 -93
- package/dist/commands/test/reporter-files.d.ts +0 -10
- package/dist/commands/test/reporter-files.js +0 -48
- package/dist/commands/test/reporter-verbose.d.ts +0 -10
- package/dist/commands/test/reporter-verbose.js +0 -56
- package/dist/commands/test.d.ts +0 -4
- package/dist/commands/test.js +0 -186
- package/dist/integrity.d.ts +0 -4
- package/dist/integrity.js +0 -92
- package/dist/out/cli.d.ts +0 -2
- package/dist/out/cli.js +0 -114581
- package/dist/parse-changelog.d.ts +0 -1
- package/dist/parse-changelog.js +0 -1435
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -1411
|
@@ -16,6 +16,11 @@ actor class() {
|
|
|
16
16
|
bench.getSchema();
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
public query func getSchema() : async Bench.BenchSchema {
|
|
20
|
+
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
21
|
+
bench.getSchema();
|
|
22
|
+
};
|
|
23
|
+
|
|
19
24
|
func _getStats() : Bench.BenchResult {
|
|
20
25
|
{
|
|
21
26
|
instructions = 0;
|
package/dist/commands/bench.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
-
|
|
4
|
+
import os from 'node:os';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { globSync } from 'glob';
|
|
7
7
|
import { markdownTable } from 'markdown-table';
|
|
@@ -14,6 +14,7 @@ import { getMocVersion } from '../helpers/get-moc-version.js';
|
|
|
14
14
|
import { getDfxVersion } from '../helpers/get-dfx-version.js';
|
|
15
15
|
import { getMocPath } from '../helpers/get-moc-path.js';
|
|
16
16
|
import { sources } from './sources.js';
|
|
17
|
+
import { execaCommand } from 'execa';
|
|
17
18
|
let ignore = [
|
|
18
19
|
'**/node_modules/**',
|
|
19
20
|
'**/.mops/**',
|
|
@@ -35,6 +36,7 @@ export async function bench(filter = '', options = {}) {
|
|
|
35
36
|
verbose: false,
|
|
36
37
|
};
|
|
37
38
|
options = { ...defaultOptions, ...options };
|
|
39
|
+
console.log(options);
|
|
38
40
|
let rootDir = getRootDir();
|
|
39
41
|
let globStr = '**/bench?(mark)/**/*.bench.mo';
|
|
40
42
|
if (filter) {
|
|
@@ -63,7 +65,10 @@ export async function bench(filter = '', options = {}) {
|
|
|
63
65
|
console.log('');
|
|
64
66
|
console.log('Starting dfx replica...');
|
|
65
67
|
startDfx(options.verbose);
|
|
66
|
-
|
|
68
|
+
console.log('Deploying canisters...');
|
|
69
|
+
await parallel(os.cpus().length, files, async (file) => {
|
|
70
|
+
await deployBenchFile(file, options);
|
|
71
|
+
});
|
|
67
72
|
await parallel(1, files, async (file) => {
|
|
68
73
|
console.log('\n' + '—'.repeat(50));
|
|
69
74
|
console.log(`\nRunning ${chalk.gray(absToRel(file))}...`);
|
|
@@ -97,11 +102,9 @@ function dfxJson(canisterName, options = {}) {
|
|
|
97
102
|
let canisters = {};
|
|
98
103
|
if (canisterName) {
|
|
99
104
|
canisters[canisterName] = {
|
|
100
|
-
// type: 'motoko',
|
|
101
105
|
type: 'custom',
|
|
102
106
|
wasm: 'canister.wasm',
|
|
103
107
|
candid: 'canister.did',
|
|
104
|
-
// args: getMocArgs(options),
|
|
105
108
|
};
|
|
106
109
|
}
|
|
107
110
|
return {
|
|
@@ -130,37 +133,47 @@ function stopDfx(verbose = false) {
|
|
|
130
133
|
let dir = path.join(getRootDir(), '.mops/.bench');
|
|
131
134
|
execSync('dfx stop' + (verbose ? '' : ' -qqqq'), { cwd: dir, stdio: ['pipe', verbose ? 'inherit' : 'ignore', 'pipe'] });
|
|
132
135
|
}
|
|
133
|
-
async function
|
|
136
|
+
async function deployBenchFile(file, options = {}) {
|
|
134
137
|
let rootDir = getRootDir();
|
|
135
138
|
let tempDir = path.join(rootDir, '.mops/.bench/', path.parse(file).name);
|
|
136
|
-
fs.mkdirSync(tempDir, { recursive: true });
|
|
137
|
-
// let canisterName = Date.now().toString(36);
|
|
138
139
|
let canisterName = path.parse(file).name;
|
|
139
140
|
// prepare temp files
|
|
141
|
+
fs.mkdirSync(tempDir, { recursive: true });
|
|
140
142
|
fs.writeFileSync(path.join(tempDir, 'dfx.json'), JSON.stringify(dfxJson(canisterName, options), null, 2));
|
|
141
143
|
fs.cpSync(new URL('./bench/bench-canister.mo', import.meta.url), path.join(tempDir, 'canister.mo'));
|
|
142
144
|
fs.cpSync(file, path.join(tempDir, 'user-bench.mo'));
|
|
143
145
|
// build canister
|
|
144
146
|
let mocPath = getMocPath();
|
|
145
147
|
let mocArgs = getMocArgs(options);
|
|
146
|
-
console.
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
options.verbose && console.time(`build ${canisterName}`);
|
|
149
|
+
await execaCommand(`${mocPath} -c --idl canister.mo ${mocArgs} ${(await sources({ cwd: tempDir })).join(' ')}`, { cwd: tempDir, stdio: options.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
|
|
150
|
+
options.verbose && console.timeEnd(`build ${canisterName}`);
|
|
151
|
+
// deploy canister
|
|
152
|
+
options.verbose && console.time(`deploy ${canisterName}`);
|
|
153
|
+
await execaCommand(`dfx deploy ${canisterName} --mode reinstall --yes --identity anonymous`, { cwd: tempDir, stdio: options.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
|
|
154
|
+
options.verbose && console.timeEnd(`deploy ${canisterName}`);
|
|
155
|
+
// init bench
|
|
156
|
+
options.verbose && console.time(`init ${canisterName}`);
|
|
157
|
+
let canisterId = execSync(`dfx canister id ${canisterName}`, { cwd: tempDir }).toString().trim();
|
|
158
|
+
let actor = await createActor(canisterId, {
|
|
159
|
+
agentOptions: {
|
|
160
|
+
host: 'http://127.0.0.1:4947',
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
await actor.init();
|
|
164
|
+
options.verbose && console.timeEnd(`init ${canisterName}`);
|
|
149
165
|
}
|
|
150
166
|
async function runBenchFile(file, options = {}) {
|
|
151
167
|
let rootDir = getRootDir();
|
|
152
|
-
await buildBenchFile(file, options);
|
|
153
168
|
let tempDir = path.join(rootDir, '.mops/.bench/', path.parse(file).name);
|
|
154
169
|
let canisterName = path.parse(file).name;
|
|
155
|
-
// deploy canister
|
|
156
|
-
execSync(`dfx deploy ${canisterName} --mode reinstall --yes --identity anonymous`, { cwd: tempDir, stdio: options.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
|
|
157
170
|
let canisterId = execSync(`dfx canister id ${canisterName}`, { cwd: tempDir }).toString().trim();
|
|
158
171
|
let actor = await createActor(canisterId, {
|
|
159
172
|
agentOptions: {
|
|
160
173
|
host: 'http://127.0.0.1:4947',
|
|
161
174
|
},
|
|
162
175
|
});
|
|
163
|
-
let schema = await actor.
|
|
176
|
+
let schema = await actor.getSchema();
|
|
164
177
|
// load previous results
|
|
165
178
|
let prevResults;
|
|
166
179
|
let resultsJsonFile = path.join(rootDir, '.bench', `${path.parse(file).name}.json`);
|
|
@@ -222,8 +235,8 @@ async function runBenchFile(file, options = {}) {
|
|
|
222
235
|
// run all cells
|
|
223
236
|
for (let [rowIndex, row] of schema.rows.entries()) {
|
|
224
237
|
for (let [colIndex, col] of schema.cols.entries()) {
|
|
225
|
-
|
|
226
|
-
let res = await actor.runCellUpdate(BigInt(rowIndex), BigInt(colIndex));
|
|
238
|
+
let res = await actor.runCellQuery(BigInt(rowIndex), BigInt(colIndex));
|
|
239
|
+
// let res = await actor.runCellUpdate(BigInt(rowIndex), BigInt(colIndex));
|
|
227
240
|
// let res = await actor.runCellUpdateAwait(BigInt(rowIndex), BigInt(colIndex));
|
|
228
241
|
results.set(`${row}:${col}`, res);
|
|
229
242
|
printResults();
|
|
@@ -16,6 +16,7 @@ export interface BenchSchema {
|
|
|
16
16
|
'description' : string,
|
|
17
17
|
}
|
|
18
18
|
export interface anon_class_10_1 {
|
|
19
|
+
'getSchema' : ActorMethod<[], BenchSchema>,
|
|
19
20
|
'getStats' : ActorMethod<[], BenchResult>,
|
|
20
21
|
'init' : ActorMethod<[], BenchSchema>,
|
|
21
22
|
'runCellQuery' : ActorMethod<[bigint, bigint], BenchResult>,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export const idlFactory = ({ IDL }) => {
|
|
2
|
+
const BenchSchema = IDL.Record({
|
|
3
|
+
'cols' : IDL.Vec(IDL.Text),
|
|
4
|
+
'name' : IDL.Text,
|
|
5
|
+
'rows' : IDL.Vec(IDL.Text),
|
|
6
|
+
'description' : IDL.Text,
|
|
7
|
+
});
|
|
2
8
|
const BenchResult = IDL.Record({
|
|
3
9
|
'instructions' : IDL.Int,
|
|
4
10
|
'rts_memory_size' : IDL.Int,
|
|
@@ -7,13 +13,8 @@ export const idlFactory = ({ IDL }) => {
|
|
|
7
13
|
'rts_mutator_instructions' : IDL.Int,
|
|
8
14
|
'rts_heap_size' : IDL.Int,
|
|
9
15
|
});
|
|
10
|
-
const BenchSchema = IDL.Record({
|
|
11
|
-
'cols' : IDL.Vec(IDL.Text),
|
|
12
|
-
'name' : IDL.Text,
|
|
13
|
-
'rows' : IDL.Vec(IDL.Text),
|
|
14
|
-
'description' : IDL.Text,
|
|
15
|
-
});
|
|
16
16
|
const anon_class_10_1 = IDL.Service({
|
|
17
|
+
'getSchema' : IDL.Func([], [BenchSchema], ['query']),
|
|
17
18
|
'getStats' : IDL.Func([], [BenchResult], ['query']),
|
|
18
19
|
'init' : IDL.Func([], [BenchSchema], []),
|
|
19
20
|
'runCellQuery' : IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], ['query']),
|
package/dist/package.json
CHANGED
package/dist/resolve-packages.js
CHANGED
|
@@ -57,7 +57,7 @@ export async function resolvePackages({ verbose = false } = {}) {
|
|
|
57
57
|
let nestedConfig;
|
|
58
58
|
if (repo) {
|
|
59
59
|
const dir = formatGithubDir(name, repo);
|
|
60
|
-
nestedConfig = await readVesselConfig(dir) || {};
|
|
60
|
+
nestedConfig = await readVesselConfig(dir, { silent: true }) || {};
|
|
61
61
|
}
|
|
62
62
|
else if (!pkgDetails.path && version) {
|
|
63
63
|
const file = formatDir(name, version) + '/mops.toml';
|
package/dist/vessel.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ export type VesselDependencies = Array<{
|
|
|
8
8
|
repo?: string;
|
|
9
9
|
path?: string;
|
|
10
10
|
}>;
|
|
11
|
-
export declare const readVesselConfig: (dir: string, { cache }?: {
|
|
11
|
+
export declare const readVesselConfig: (dir: string, { cache, silent }?: {
|
|
12
12
|
cache?: boolean | undefined;
|
|
13
|
+
silent?: boolean | undefined;
|
|
13
14
|
}) => Promise<VesselConfig | null>;
|
|
14
15
|
export declare const downloadFromGithub: (repo: string, dest: string, onProgress: any) => Promise<unknown>;
|
|
15
16
|
export declare const installFromGithub: (name: string, repo: string, { verbose, dep, silent }?: {
|
package/dist/vessel.js
CHANGED
|
@@ -9,7 +9,7 @@ import decompress from 'decompress';
|
|
|
9
9
|
import { pipeline } from 'stream';
|
|
10
10
|
import { formatGithubDir, parseGithubURL, progressBar } from './mops.js';
|
|
11
11
|
import { addCache, copyCache, isCached } from './cache.js';
|
|
12
|
-
const dhallFileToJson = async (filePath) => {
|
|
12
|
+
const dhallFileToJson = async (filePath, silent) => {
|
|
13
13
|
if (existsSync(filePath)) {
|
|
14
14
|
let cwd = new URL(path.dirname(import.meta.url)).pathname;
|
|
15
15
|
let res;
|
|
@@ -17,7 +17,7 @@ const dhallFileToJson = async (filePath) => {
|
|
|
17
17
|
res = await execaCommand(`dhall-to-json --file ${filePath}`, { preferLocal: true, cwd });
|
|
18
18
|
}
|
|
19
19
|
catch (err) {
|
|
20
|
-
console.error('dhall-to-json error:', err);
|
|
20
|
+
silent || console.error('dhall-to-json error:', err.message?.split('Message:')[0]);
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
if (res.exitCode === 0) {
|
|
@@ -29,15 +29,15 @@ const dhallFileToJson = async (filePath) => {
|
|
|
29
29
|
}
|
|
30
30
|
return null;
|
|
31
31
|
};
|
|
32
|
-
export const readVesselConfig = async (dir, { cache = true } = {}) => {
|
|
32
|
+
export const readVesselConfig = async (dir, { cache = true, silent = false } = {}) => {
|
|
33
33
|
const cachedFile = (dir || process.cwd()) + '/vessel.json';
|
|
34
34
|
if (existsSync(cachedFile)) {
|
|
35
35
|
let cachedConfig = readFileSync(cachedFile).toString();
|
|
36
36
|
return JSON.parse(cachedConfig);
|
|
37
37
|
}
|
|
38
38
|
const [vessel, packageSetArray] = await Promise.all([
|
|
39
|
-
dhallFileToJson((dir || process.cwd()) + '/vessel.dhall'),
|
|
40
|
-
dhallFileToJson((dir || process.cwd()) + '/package-set.dhall')
|
|
39
|
+
dhallFileToJson((dir || process.cwd()) + '/vessel.dhall', silent),
|
|
40
|
+
dhallFileToJson((dir || process.cwd()) + '/package-set.dhall', silent)
|
|
41
41
|
]);
|
|
42
42
|
if (!vessel || !packageSetArray) {
|
|
43
43
|
return null;
|
|
@@ -64,6 +64,8 @@ export const downloadFromGithub = async (repo, dest, onProgress) => {
|
|
|
64
64
|
const readStream = got.stream(zipFile);
|
|
65
65
|
const promise = new Promise((resolve, reject) => {
|
|
66
66
|
readStream.on('error', (err) => {
|
|
67
|
+
console.error(chalk.red(`Error: failed to download from GitHub: ${zipFile}`));
|
|
68
|
+
console.error(err.message);
|
|
67
69
|
reject(err);
|
|
68
70
|
});
|
|
69
71
|
readStream.on('downloadProgress', ({ transferred, total }) => {
|
|
@@ -135,7 +137,7 @@ export const installFromGithub = async (name, repo, { verbose = false, dep = fal
|
|
|
135
137
|
}
|
|
136
138
|
catch (err) {
|
|
137
139
|
deleteSync([dir]);
|
|
138
|
-
|
|
140
|
+
process.exit(1);
|
|
139
141
|
}
|
|
140
142
|
// add to cache
|
|
141
143
|
await addCache(cacheName, dir);
|
|
@@ -143,7 +145,7 @@ export const installFromGithub = async (name, repo, { verbose = false, dep = fal
|
|
|
143
145
|
if (verbose) {
|
|
144
146
|
silent || logUpdate.done();
|
|
145
147
|
}
|
|
146
|
-
const config = await readVesselConfig(dir);
|
|
148
|
+
const config = await readVesselConfig(dir, { silent });
|
|
147
149
|
if (config) {
|
|
148
150
|
for (const { name, repo } of config.dependencies) {
|
|
149
151
|
if (repo) {
|
package/package.json
CHANGED
package/resolve-packages.ts
CHANGED
|
@@ -71,7 +71,7 @@ export async function resolvePackages({verbose = false} = {}): Promise<Record<st
|
|
|
71
71
|
|
|
72
72
|
if (repo) {
|
|
73
73
|
const dir = formatGithubDir(name, repo);
|
|
74
|
-
nestedConfig = await readVesselConfig(dir) || {};
|
|
74
|
+
nestedConfig = await readVesselConfig(dir, {silent: true}) || {};
|
|
75
75
|
}
|
|
76
76
|
else if (!pkgDetails.path && version) {
|
|
77
77
|
const file = formatDir(name, version) + '/mops.toml';
|
package/vessel.ts
CHANGED
|
@@ -10,15 +10,15 @@ import {pipeline} from 'stream';
|
|
|
10
10
|
import {formatGithubDir, parseGithubURL, progressBar} from './mops.js';
|
|
11
11
|
import {addCache, copyCache, isCached} from './cache.js';
|
|
12
12
|
|
|
13
|
-
const dhallFileToJson = async (filePath: string) => {
|
|
13
|
+
const dhallFileToJson = async (filePath: string, silent: boolean) => {
|
|
14
14
|
if (existsSync(filePath)) {
|
|
15
15
|
let cwd = new URL(path.dirname(import.meta.url)).pathname;
|
|
16
16
|
let res;
|
|
17
17
|
try {
|
|
18
18
|
res = await execaCommand(`dhall-to-json --file ${filePath}`, {preferLocal:true, cwd});
|
|
19
19
|
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
console.error('dhall-to-json error:', err);
|
|
20
|
+
catch (err: any) {
|
|
21
|
+
silent || console.error('dhall-to-json error:', err.message?.split('Message:')[0]);
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -45,7 +45,7 @@ export type VesselDependencies = Array<{
|
|
|
45
45
|
path?: string; // local package
|
|
46
46
|
}>;
|
|
47
47
|
|
|
48
|
-
export const readVesselConfig = async (dir: string, {cache = true} = {}): Promise<VesselConfig | null> => {
|
|
48
|
+
export const readVesselConfig = async (dir: string, {cache = true, silent = false} = {}): Promise<VesselConfig | null> => {
|
|
49
49
|
const cachedFile = (dir || process.cwd()) + '/vessel.json';
|
|
50
50
|
|
|
51
51
|
if (existsSync(cachedFile)) {
|
|
@@ -54,8 +54,8 @@ export const readVesselConfig = async (dir: string, {cache = true} = {}): Promis
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const [vessel, packageSetArray] = await Promise.all([
|
|
57
|
-
dhallFileToJson((dir || process.cwd()) + '/vessel.dhall'),
|
|
58
|
-
dhallFileToJson((dir || process.cwd()) + '/package-set.dhall')
|
|
57
|
+
dhallFileToJson((dir || process.cwd()) + '/vessel.dhall', silent),
|
|
58
|
+
dhallFileToJson((dir || process.cwd()) + '/package-set.dhall', silent)
|
|
59
59
|
]);
|
|
60
60
|
|
|
61
61
|
if (!vessel || !packageSetArray) {
|
|
@@ -90,6 +90,8 @@ export const downloadFromGithub = async (repo: string, dest: string, onProgress:
|
|
|
90
90
|
|
|
91
91
|
const promise = new Promise((resolve, reject) => {
|
|
92
92
|
readStream.on('error', (err) => {
|
|
93
|
+
console.error(chalk.red(`Error: failed to download from GitHub: ${zipFile}`));
|
|
94
|
+
console.error(err.message);
|
|
93
95
|
reject(err);
|
|
94
96
|
});
|
|
95
97
|
|
|
@@ -172,7 +174,7 @@ export const installFromGithub = async (name: string, repo: string, {verbose = f
|
|
|
172
174
|
}
|
|
173
175
|
catch (err) {
|
|
174
176
|
deleteSync([dir]);
|
|
175
|
-
|
|
177
|
+
process.exit(1);
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
// add to cache
|
|
@@ -183,7 +185,7 @@ export const installFromGithub = async (name: string, repo: string, {verbose = f
|
|
|
183
185
|
silent || logUpdate.done();
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
const config = await readVesselConfig(dir);
|
|
188
|
+
const config = await readVesselConfig(dir, {silent});
|
|
187
189
|
|
|
188
190
|
if (config) {
|
|
189
191
|
for (const {name, repo} of config.dependencies) {
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Nat "mo:base/Nat";
|
|
2
|
-
import Iter "mo:base/Iter";
|
|
3
|
-
import Buffer "mo:base/Buffer";
|
|
4
|
-
import Vector "mo:vector/Class";
|
|
5
|
-
// import Bench "./bench";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
module {
|
|
9
|
-
public func init() : Bench.Bench {
|
|
10
|
-
let bench = Bench.Bench();
|
|
11
|
-
|
|
12
|
-
bench.setName("Add items one-by-one");
|
|
13
|
-
|
|
14
|
-
bench.addRow("Vector");
|
|
15
|
-
bench.addRow("Buffer");
|
|
16
|
-
|
|
17
|
-
bench.addCol("10");
|
|
18
|
-
bench.addCol("10000");
|
|
19
|
-
bench.addCol("1000000");
|
|
20
|
-
|
|
21
|
-
bench.setRunner(func(row, col) {
|
|
22
|
-
let ?n = Nat.fromText(col);
|
|
23
|
-
|
|
24
|
-
// Vector
|
|
25
|
-
if (row == "Vector") {
|
|
26
|
-
let vec = Vector.Vector<Nat>();
|
|
27
|
-
for (i in Iter.range(1, n)) {
|
|
28
|
-
vec.add(i);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Buffer
|
|
32
|
-
else if (row == "Buffer") {
|
|
33
|
-
let buf = Buffer.Buffer<Nat>(0);
|
|
34
|
-
for (i in Iter.range(1, n)) {
|
|
35
|
-
buf.add(i);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// bench.table(["Vector", "Buffer"], ["10", "10000", "1000000"], func(row, col) {
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
bench;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import Nat64 "mo:base/Nat64";
|
|
2
|
-
import Debug "mo:base/Debug";
|
|
3
|
-
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
4
|
-
import Prim "mo:prim";
|
|
5
|
-
|
|
6
|
-
// import Bench "./bench";
|
|
7
|
-
import Bench "mo:bench";
|
|
8
|
-
|
|
9
|
-
import UserBench "$USER_BENCH_FILE";
|
|
10
|
-
|
|
11
|
-
actor class() {
|
|
12
|
-
var benchOpt : ?Bench.Bench = null;
|
|
13
|
-
|
|
14
|
-
public func init() : async Bench.BenchSchema {
|
|
15
|
-
let bench = UserBench.init();
|
|
16
|
-
benchOpt := ?bench;
|
|
17
|
-
bench.getSchema();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// public composite query func noop() : async () {};
|
|
21
|
-
|
|
22
|
-
public func runCell(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
23
|
-
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
24
|
-
|
|
25
|
-
let rts_heap_size_before = Prim.rts_heap_size();
|
|
26
|
-
let rts_memory_size_before = Prim.rts_memory_size();
|
|
27
|
-
let rts_total_allocation_before = Prim.rts_total_allocation();
|
|
28
|
-
let rts_mutator_instructions_before = Prim.rts_mutator_instructions();
|
|
29
|
-
let rts_collector_instructions_before = Prim.rts_collector_instructions();
|
|
30
|
-
|
|
31
|
-
let mode : Bench.BenchMode = #replica;
|
|
32
|
-
let instructions = switch(mode) {
|
|
33
|
-
case (#replica) {
|
|
34
|
-
ExperimentalInternetComputer.countInstructions(func() {
|
|
35
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
case (#wasi) {
|
|
39
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
40
|
-
0 : Nat64;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// await noop();
|
|
45
|
-
|
|
46
|
-
// await (func() : async () {})();
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
instructions = Nat64.toNat(instructions);
|
|
50
|
-
rts_heap_size = Prim.rts_heap_size() - rts_heap_size_before;
|
|
51
|
-
rts_memory_size = Prim.rts_memory_size() - rts_memory_size_before;
|
|
52
|
-
rts_total_allocation = Prim.rts_total_allocation() - rts_total_allocation_before;
|
|
53
|
-
rts_mutator_instructions = Prim.rts_mutator_instructions() - rts_mutator_instructions_before;
|
|
54
|
-
rts_collector_instructions = Prim.rts_collector_instructions() - rts_collector_instructions_before;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Nat "mo:base/Nat";
|
|
2
|
-
import Iter "mo:base/Iter";
|
|
3
|
-
import Buffer "mo:base/Buffer";
|
|
4
|
-
import Vector "mo:vector/Class";
|
|
5
|
-
// import Bench "./bench";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
module {
|
|
9
|
-
public func init() : Bench.Bench {
|
|
10
|
-
let bench = Bench.Bench();
|
|
11
|
-
|
|
12
|
-
bench.setName("Add items one-by-one");
|
|
13
|
-
|
|
14
|
-
bench.addRow("Vector");
|
|
15
|
-
bench.addRow("Buffer");
|
|
16
|
-
|
|
17
|
-
bench.addCol("10");
|
|
18
|
-
bench.addCol("10000");
|
|
19
|
-
bench.addCol("1000000");
|
|
20
|
-
|
|
21
|
-
bench.setRunner(func(row, col) {
|
|
22
|
-
let ?n = Nat.fromText(col);
|
|
23
|
-
|
|
24
|
-
// Vector
|
|
25
|
-
if (row == "Vector") {
|
|
26
|
-
let vec = Vector.Vector<Nat>();
|
|
27
|
-
for (i in Iter.range(1, n)) {
|
|
28
|
-
vec.add(i);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Buffer
|
|
32
|
-
else if (row == "Buffer") {
|
|
33
|
-
let buf = Buffer.Buffer<Nat>(0);
|
|
34
|
-
for (i in Iter.range(1, n)) {
|
|
35
|
-
buf.add(i);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// bench.table(["Vector", "Buffer"], ["10", "10000", "1000000"], func(row, col) {
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
bench;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import Nat "mo:base/Nat";
|
|
2
|
-
import Iter "mo:base/Iter";
|
|
3
|
-
import Buffer "mo:base/Buffer";
|
|
4
|
-
import Vector "mo:vector/Class";
|
|
5
|
-
// import Bench "./bench";
|
|
6
|
-
import Bench "mo:bench";
|
|
7
|
-
|
|
8
|
-
module {
|
|
9
|
-
public func init() : Bench.Bench {
|
|
10
|
-
let bench = Bench.Bench();
|
|
11
|
-
|
|
12
|
-
bench.setName("Add items one-by-one");
|
|
13
|
-
|
|
14
|
-
bench.addRow("Vector");
|
|
15
|
-
bench.addRow("Buffer");
|
|
16
|
-
|
|
17
|
-
bench.addCol("10");
|
|
18
|
-
bench.addCol("10000");
|
|
19
|
-
bench.addCol("1000000");
|
|
20
|
-
|
|
21
|
-
bench.setRunner(func(row, col) {
|
|
22
|
-
let ?n = Nat.fromText(col);
|
|
23
|
-
|
|
24
|
-
// Vector
|
|
25
|
-
if (row == "Vector") {
|
|
26
|
-
let vec = Vector.Vector<Nat>();
|
|
27
|
-
for (i in Iter.range(1, n)) {
|
|
28
|
-
vec.add(i);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// Buffer
|
|
32
|
-
else if (row == "Buffer") {
|
|
33
|
-
let buf = Buffer.Buffer<Nat>(0);
|
|
34
|
-
for (i in Iter.range(1, n)) {
|
|
35
|
-
buf.add(i);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// bench.table(["Vector", "Buffer"], ["10", "10000", "1000000"], func(row, col) {
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
bench;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import Nat64 "mo:base/Nat64";
|
|
2
|
-
import Debug "mo:base/Debug";
|
|
3
|
-
import ExperimentalInternetComputer "mo:base/ExperimentalInternetComputer";
|
|
4
|
-
import Prim "mo:prim";
|
|
5
|
-
|
|
6
|
-
// import Bench "./bench";
|
|
7
|
-
import Bench "mo:bench";
|
|
8
|
-
|
|
9
|
-
import UserBench "$USER_BENCH_FILE";
|
|
10
|
-
|
|
11
|
-
actor class() {
|
|
12
|
-
var benchOpt : ?Bench.Bench = null;
|
|
13
|
-
|
|
14
|
-
public func init() : async Bench.BenchSchema {
|
|
15
|
-
let bench = UserBench.init();
|
|
16
|
-
benchOpt := ?bench;
|
|
17
|
-
bench.getSchema();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// public composite query func noop() : async () {};
|
|
21
|
-
|
|
22
|
-
public func runCell(rowIndex : Nat, colIndex : Nat) : async Bench.BenchResult {
|
|
23
|
-
let ?bench = benchOpt else Debug.trap("bench not initialized");
|
|
24
|
-
|
|
25
|
-
let rts_heap_size_before = Prim.rts_heap_size();
|
|
26
|
-
let rts_memory_size_before = Prim.rts_memory_size();
|
|
27
|
-
let rts_total_allocation_before = Prim.rts_total_allocation();
|
|
28
|
-
let rts_mutator_instructions_before = Prim.rts_mutator_instructions();
|
|
29
|
-
let rts_collector_instructions_before = Prim.rts_collector_instructions();
|
|
30
|
-
|
|
31
|
-
let mode : Bench.BenchMode = #replica;
|
|
32
|
-
let instructions = switch(mode) {
|
|
33
|
-
case (#replica) {
|
|
34
|
-
ExperimentalInternetComputer.countInstructions(func() {
|
|
35
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
case (#wasi) {
|
|
39
|
-
bench.runCell(rowIndex, colIndex, #replica);
|
|
40
|
-
0 : Nat64;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// await noop();
|
|
45
|
-
|
|
46
|
-
// await (func() : async () {})();
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
instructions = Nat64.toNat(instructions);
|
|
50
|
-
rts_heap_size = Prim.rts_heap_size() - rts_heap_size_before;
|
|
51
|
-
rts_memory_size = Prim.rts_memory_size() - rts_memory_size_before;
|
|
52
|
-
rts_total_allocation = Prim.rts_total_allocation() - rts_total_allocation_before;
|
|
53
|
-
rts_mutator_instructions = Prim.rts_mutator_instructions() - rts_mutator_instructions_before;
|
|
54
|
-
rts_collector_instructions = Prim.rts_collector_instructions() - rts_collector_instructions_before;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const idlFactory = ({ IDL }) => {
|
|
2
|
-
const BenchSchema = IDL.Record({
|
|
3
|
-
'title': IDL.Text,
|
|
4
|
-
'cols': IDL.Vec(IDL.Text),
|
|
5
|
-
'rows': IDL.Vec(IDL.Text),
|
|
6
|
-
'description': IDL.Text,
|
|
7
|
-
});
|
|
8
|
-
const BenchResult = IDL.Record({
|
|
9
|
-
'instructions': IDL.Nat,
|
|
10
|
-
'rts_memory_size': IDL.Nat,
|
|
11
|
-
'rts_total_allocation': IDL.Nat,
|
|
12
|
-
'rts_collector_instructions': IDL.Nat,
|
|
13
|
-
'rts_mutator_instructions': IDL.Nat,
|
|
14
|
-
'rts_heap_size': IDL.Nat,
|
|
15
|
-
});
|
|
16
|
-
const anon_class_11_1 = IDL.Service({
|
|
17
|
-
'init': IDL.Func([], [BenchSchema], []),
|
|
18
|
-
'runCell': IDL.Func([IDL.Nat, IDL.Nat], [BenchResult], []),
|
|
19
|
-
});
|
|
20
|
-
return anon_class_11_1;
|
|
21
|
-
};
|
|
22
|
-
export const init = ({ IDL }) => { return []; };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
|
-
// Imports and re-exports candid interface
|
|
3
|
-
import { idlFactory } from "./bench.did.js";
|
|
4
|
-
export { idlFactory } from "./bench.did.js";
|
|
5
|
-
/* CANISTER_ID is replaced by webpack based on node environment
|
|
6
|
-
* Note: canister environment variable will be standardized as
|
|
7
|
-
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE>
|
|
8
|
-
* beginning in dfx 0.15.0
|
|
9
|
-
*/
|
|
10
|
-
export const canisterId = process.env.CANISTER_ID_BENCH ||
|
|
11
|
-
process.env.BENCH_CANISTER_ID;
|
|
12
|
-
export const createActor = (canisterId, options = {}) => {
|
|
13
|
-
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
14
|
-
if (options.agent && options.agentOptions) {
|
|
15
|
-
console.warn("Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent.");
|
|
16
|
-
}
|
|
17
|
-
// Fetch root key for certificate validation during development
|
|
18
|
-
if (process.env.DFX_NETWORK !== "ic") {
|
|
19
|
-
agent.fetchRootKey().catch((err) => {
|
|
20
|
-
console.warn("Unable to fetch root key. Check to ensure that your local replica is running");
|
|
21
|
-
console.error(err);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
// Creates an actor with using the candid interface and the HttpAgent
|
|
25
|
-
return Actor.createActor(idlFactory, {
|
|
26
|
-
agent,
|
|
27
|
-
canisterId,
|
|
28
|
-
...options.actorOptions,
|
|
29
|
-
});
|
|
30
|
-
};
|