Skip to content

Commit c8113d0

Browse files
author
mike dupont
committed
increasing the load on the simple functions
adding in more test functions. This is also usable on the cli `run-all-tests.sh` runs the test outside docker as well.
1 parent 3319657 commit c8113d0

11 files changed

+61
-44
lines changed

Dockerfile

+14-12
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ RUN pnpm run build
4545
#RUN apt update
4646
#RUN apt install -y strace
4747
run apt-get install -y linux-perf # move to top
48-
COPY run-jest-tests.sh /app/run-jest-tests.sh
49-
COPY jest.config.js /app/jest.config.js
50-
COPY run-integration-tests.sh /app/run-integration-tests.sh
51-
COPY run-unit-tests.sh /app/run-unit-tests.sh
52-
COPY run-all-tests.sh /app/run-all-tests.sh
53-
COPY run /app/run
54-
COPY run-debug /app/run-debug
55-
COPY run-minimal-mina-tests.sh /app/run-minimal-mina-tests.sh
56-
COPY run-ci-benchmarks.sh /app/run-ci-benchmarks.sh
5748

5849
# why is this needed?
5950
RUN ln -s /app/dist /app/src/mina-signer/dist
@@ -67,11 +58,10 @@ RUN ln -s /app/dist /app/src/mina-signer/dist
6758
#run apt-get update
6859

6960

70-
CMD [ "pnpm", "run", "test" ]
71-
61+
#CMD [ "pnpm", "run", "test" ]
7262
#RUN pnpm run test || echo skip errors
7363

74-
COPY . /app
64+
#COPY . /app
7565
WORKDIR /app
7666

7767
FROM base AS prod-deps
@@ -84,6 +74,18 @@ RUN pnpm run build
8474
FROM base
8575
COPY --from=prod-deps /app/node_modules /app/node_modules
8676
COPY --from=build /app/dist /app/dist
77+
78+
COPY run-jest-tests.sh /app/run-jest-tests.sh
79+
COPY jest.config.js /app/jest.config.js
80+
COPY run-integration-tests.sh /app/run-integration-tests.sh
81+
COPY run-unit-tests.sh /app/run-unit-tests.sh
82+
COPY run-all-tests.sh /app/run-all-tests.sh
83+
COPY run /app/run
84+
COPY run-debug /app/run-debug
85+
COPY run-minimal-mina-tests.sh /app/run-minimal-mina-tests.sh
86+
COPY run-ci-benchmarks.sh /app/run-ci-benchmarks.sh
87+
88+
8789
EXPOSE 8000
8890
CMD [ "pnpm", "start" ]
8991

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
test:
22
docker compose build mina-local-network
3-
docker compose up mina-local-network
3+
docker compose up mina-local-network

run-all-tests.sh

100644100755
+30-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
1+
#!/bin/bash
22
set +e
3-
3+
export OUTPUT_DIR="/tmp/perf"
4+
export NODE_OUTPUT_DIR="${OUTPUT_DIR}/node"
5+
export CLINIC_OUTPUT_DIR="${OUTPUT_DIR}/clinic"
6+
mkdir "${OUTPUT_DIR}"
7+
mkdir "${NODE_OUTPUT_DIR}"
8+
mkdir "${CLINIC_OUTPUT_DIR}"
9+
export NODE_OPTIONS="--experimental-vm-modules --perf-basic-prof --enable-source-maps --stack-trace-limit=1000 --report-dir $NODE_OUTPUT_DIR --perf-prof-unwinding-info --perf-prof"
10+
# --trace-events-enabled
411
#NO_INSIGHT=true clinic doctor -- node --perf-basic-prof --enable-source-maps --stack-trace-limit=1000 ./node_modules/jest-cli/bin/jest.js
512
#NO_INSIGHT=true clinic flame -- node --perf-basic-prof --enable-source-maps --stack-trace-limit=1000 ./node_modules/jest-cli/bin/jest.js
613
# May Clinic.js report anonymous usage statistics to improve the tool over time?
@@ -10,14 +17,13 @@ set +e
1017
#NO_INSIGHT=true clinic doctor --collect-only --
1118
#node /usr/local/bin/pnpm run test
1219
#./run-jest-tests.sh
13-
export NODE_OPTIONS=--experimental-vm-modules
20+
1421
#export NO_INSIGHT=true
1522
#npx jest
1623
#clinic doctor -- node ./node_modules/.bin/../jest/bin/jest.js src/lib/provable/test/int.test.ts
1724
echo 2 > /proc/sys/kernel/perf_event_paranoid
1825

1926

20-
2127
# mdupont@mdupont-G470:~/2024/09/20/o1js$ grep PASS report1.txt
2228
# PASS src/lib/provable/test/merkle-list.test.ts (7.118 s)
2329
# PASS src/lib/provable/test/merkle-tree.test.ts (7.297 s)
@@ -30,54 +36,47 @@ echo 2 > /proc/sys/kernel/perf_event_paranoid
3036
# PASS src/lib/mina/precondition.test.ts (12.688 s)
3137
# PASS src/lib/mina/token.test.ts (46.593 s)
3238

33-
mkdir /tmp/perf/
34-
TESTS="src/lib/provable/test/merkle-list.test.ts src/lib/provable/test/merkle-tree.test.ts src/lib/provable/test/scalar.test.ts src/lib/provable/test/merkle-map.test.ts src/lib/provable/test/provable.test.ts src/lib/provable/test/primitives.test.ts src/lib/provable/test/group.test.ts src/lib/provable/test/int.test.ts src/lib/mina/precondition.test.ts src/lib/mina/token.test.ts"
35-
export NO_INSIGHT=true
39+
TESTS=`ls -b src/lib/provable/test/*.test.ts src/lib/mina/*.test.ts `
40+
#src/lib/provable/test/*unit-test.ts
41+
#src/lib/mina/*.unit-test.ts
3642

43+
#TESTS="src/lib/provable/test/merkle-list-perf.test.ts"
44+
45+
export NO_INSIGHT=true
46+
export JESTOPTS=--collectCoverage
47+
export NODEOPT1="--prof --expose-gc"
3748
for testname in $TESTS;
3849
do
39-
perfdata=${testname}.perf.data
40-
clinic flame -- node --perf-basic-prof ./node_modules/.bin/../jest/bin/jest.js ${testname}
41-
clinic doctor -- node --perf-basic-prof ./node_modules/.bin/../jest/bin/jest.js ${testname}
42-
clinic bubbleprof -- node --perf-basic-prof ./node_modules/.bin/../jest/bin/jest.js ${testname}
43-
clinic heapprofiler -- node --perf-basic-prof ./node_modules/.bin/../jest/bin/jest.js ${testname}
50+
export MULTIPLE="${testname}"
51+
export perfdata="${testname}.perf.data"
52+
clinic flame -- node $NODEOPT1 ./node_modules/.bin/../jest/bin/jest.js "${JESTOPTS}" "${MULTIPLE}"
53+
clinic doctor -- node $NODEOPT1 ./node_modules/.bin/../jest/bin/jest.js "${JESTOPTS}" "${MULTIPLE}"
54+
clinic bubbleprof -- node $NODEOPT1 ./node_modules/.bin/../jest/bin/jest.js "${JESTOPTS}" "${MULTIPLE}"
55+
clinic heapprofiler -- node $NODEOPT1 ./node_modules/.bin/../jest/bin/jest.js "${JESTOPTS}" "${MULTIPLE}"
4456

45-
perf record -g -o ${testname}.perf.data -F 999 --call-graph dwarf node --perf-basic-prof ./node_modules/.bin/../jest/bin/jest.js ${testname} > ${testname}.reportout.txt 2>&1
57+
perf record -g -o "${testname}.perf.data" -F 999 --call-graph dwarf node $NODEOPT1 ./node_modules/.bin/../jest/bin/jest.js "${JESTOPTS}" "${MULTIPLE}" > "${testname}.reportout.txt" 2>&1
4658
perf archive ${testname}.perf.data
4759
perf report -i "${perfdata}" --verbose --stdio --header > "${perfdata}.header.txt" 2>&1
4860
perf report -i "${perfdata}" --verbose --stdio --stats > "${perfdata}.stats.txt" 2>&1
4961
perf script -F +pid -i "${perfdata}" > "${perfdata}.script.txt" 2>&1
5062
perf report --stdio -i "${perfdata}" > "${perfdata}.report.txt" 2>&1
51-
52-
cp ${testname}.* /tmp/perf/
53-
mkdir /tmp/perf/clinic
54-
cp -r .clinic/* /tmp/perf/clinic
63+
cp ${testname}.* "${OUTPUT_DIR}"
64+
cp -r .clinic/* "${CLINIC_OUTPUT_DIR}"
65+
cp -r coverage/* "${OUTPUT_DIR}/"
66+
cp -r jit*.dump "${OUTPUT_DIR}/"
67+
cp -r *.log "${OUTPUT_DIR}/"
5568
done
5669

5770
tar -czf /tmp/perf.data.tar.gz /tmp/perf/*
58-
#perf script > perf_script.txt
59-
#perf report > perf_report.txt
60-
#clinic doctor --collect-only -- node ./node_modules/jest-cli/bin/jest.js ./src/mina-signer/tests/rosetta.test.ts
61-
#clinic doctor --collect-only -- node ./node_modules/.pnpm/@jest+monorepo@https+++codeload.github.com+meta-introspector+jest+tar.gz+4a58402556ecd05ca9cc01873db6fbc5596ccc67/node_modules/@jest/monorepo/packages/jest-cli/bin/jest.js ./src/mina-signer/tests/rosetta.test.ts
6271

6372
# + for f in ./src/**/*.test.ts
6473
#./src/lib/mina/precondition.test.ts
6574
#./src/lib/mina/token.test.ts
6675
#./src/lib/provable/test/primitives.test.ts
6776

68-
# NO_INSIGHT=true clinic doctor --collect-only -- node /usr/local/bin/pnpm run test:integration
69-
# NO_INSIGHT=true clinic doctor --collect-only -- node /usr/local/bin/pnpm run test:unit
70-
# NO_INSIGHT=true clinic doctor --collect-only -- node /usr/local/bin/pnpm run test:e2e
71-
7277
# #######
7378
# NO_INSIGHT=true clinic flame -- node /usr/local/bin/pnpm run test
7479
# NO_INSIGHT=true clinic flame -- node /usr/local/bin/pnpm run test:integration
7580
# NO_INSIGHT=true clinic flame -- node /usr/local/bin/pnpm run test:unit
7681
# NO_INSIGHT=true clinic flame -- node /usr/local/bin/pnpm run test:e2e
7782

78-
# #clinic flame -- node index.js
79-
80-
# # pnpm run test
81-
# # pnpm run test:integration
82-
# # pnpm run test:unit
83-
# # pnpm run test:e2e

src/lib/provable/test/group.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Bool, Group, Scalar, Provable } from 'o1js';
22

3+
describe(' performance test', () => {for (let i = 0; i < 200; i++) {
34
describe('group', () => {
45
let g = Group({ x: -1, y: 2 });
56

@@ -371,3 +372,4 @@ describe('group', () => {
371372
});
372373
});
373374
});
375+
}});

src/lib/provable/test/int.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Sign,
1010
} from 'o1js';
1111

12+
describe(' performance test', () => {for (let i = 0; i < 200; i++) {
1213
describe('int', () => {
1314
const NUMBERMAX = 2 ** 53 - 1; // JavaScript numbers can only safely store integers in the range -(2^53 − 1) to 2^53 − 1
1415

@@ -2686,3 +2687,4 @@ describe('int', () => {
26862687
});
26872688
});
26882689
});
2690+
}});

src/lib/provable/test/merkle-list.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Field, MerkleList, Poseidon } from 'o1js';
22

3+
describe('performance test', () => {for (let i = 0; i < 200; i++) {
34
describe('Merkle List and Iterator', () => {
45
describe('primitive data structures', () => {
56
const emptyHash = Poseidon.hash([Field(0)]);
@@ -97,3 +98,4 @@ describe('Merkle List and Iterator', () => {
9798
});
9899
});
99100
});
101+
}});

src/lib/provable/test/merkle-map.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Field, MerkleMap } from 'o1js';
22

3+
describe('performance test', () => {for (let i = 0; i < 200; i++) {
34
describe('Merkle Map', () => {
45
it('set and get a value from a key', () => {
56
const map = new MerkleMap();
@@ -36,3 +37,4 @@ describe('Merkle Map', () => {
3637
);
3738
});
3839
});
40+
}});

src/lib/provable/test/merkle-tree.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Poseidon, Field, MerkleTree, MerkleWitness } from 'o1js';
22

3+
describe('performance test', () => {for (let i = 0; i < 200; i++) {
34
describe('Merkle Tree', () => {
45
it('root of empty tree of size 1', () => {
56
const tree = new MerkleTree(1);
@@ -77,3 +78,4 @@ describe('Merkle Tree', () => {
7778
expect(witness.toJSON()).toEqual(expectedWitness);
7879
});
7980
});
81+
}});

src/lib/provable/test/primitives.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Field, Bool, Provable } from 'o1js';
2+
describe('performance test', () => {for (let i = 0; i < 200; i++) {
23
describe('bool', () => {
34
describe('inside circuit', () => {
45
describe('toField', () => {
@@ -366,3 +367,4 @@ describe('bool', () => {
366367
});
367368
});
368369
});
370+
}});

src/lib/provable/test/provable.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
PublicKey,
99
} from 'o1js';
1010

11+
describe('performance test', () => {for (let i = 0; i < 200; i++) {
1112
describe('Provable', () => {
1213
it('Provable.if out of snark', () => {
1314
let x = Provable.if(Bool(false), Int64, Int64.from(-1), Int64.from(-2));
@@ -191,3 +192,4 @@ describe('Provable', () => {
191192
expect(reconstructed.toString()).toEqual(original.toString());
192193
});
193194
});
195+
}});

src/lib/provable/test/scalar.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Field, Provable, Scalar, ScalarField } from 'o1js';
22

3+
describe('performance test', () => {for (let i = 0; i < 200; i++) {
34
describe('scalar', () => {
45
describe('scalar', () => {
56
describe('Inside circuit', () => {
@@ -219,3 +220,4 @@ describe('scalar', () => {
219220
});
220221
});
221222
});
223+
}});

0 commit comments

Comments
 (0)