Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
build/
proto/
out/
system-test/busybench-js/src/busybench.js
3 changes: 2 additions & 1 deletion system-test/busybench-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
"license": "ISC",
"type": "module"
}
13 changes: 4 additions & 9 deletions system-test/busybench-js/src/busybench.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
* limitations under the License.
*/

const fs = require('fs');
// eslint-disable-next-line node/no-extraneous-require
const pify = require('pify');
// eslint-disable-next-line node/no-missing-require
const pprof = require('pprof');

const writeFilePromise = pify(fs.writeFile);
import fs from 'fs';
import pprof from 'pprof';

const startTime = Date.now();
const testArr = [];
Expand Down Expand Up @@ -59,13 +54,13 @@ async function collectAndSaveTimeProfile(
sourceMapper: sourceMapper,
});
const buf = await pprof.encode(profile);
await writeFilePromise('time.pb.gz', buf);
await fs.promises.writeFile('time.pb.gz', buf);
}

async function collectAndSaveHeapProfile(sourceMapper) {
const profile = pprof.heap.profile(undefined, sourceMapper);
const buf = await pprof.encode(profile);
await writeFilePromise('heap.pb.gz', buf);
await fs.promises.writeFile('heap.pb.gz', buf);
}

async function collectAndSaveProfiles(collectLineNumberTimeProfile) {
Expand Down
11 changes: 4 additions & 7 deletions system-test/busybench/src/busybench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
* limitations under the License.
*/

import {writeFile} from 'fs';
// eslint-disable-next-line node/no-extraneous-import
import * as pify from 'pify';
// eslint-disable-next-line node/no-unsupported-features/node-builtins
import {promises} from 'fs';
// eslint-disable-next-line node/no-extraneous-import
import {encode, heap, SourceMapper, time} from 'pprof';

const writeFilePromise = pify(writeFile);

const startTime: number = Date.now();
const testArr: number[][] = [];

Expand Down Expand Up @@ -57,15 +54,15 @@ async function collectAndSaveTimeProfile(
sourceMapper,
});
const buf = await encode(profile);
await writeFilePromise('time.pb.gz', buf);
await promises.writeFile('time.pb.gz', buf);
}

async function collectAndSaveHeapProfile(
sourceMapper: SourceMapper
): Promise<void> {
const profile = await heap.profile(undefined, sourceMapper);
const buf = await encode(profile);
await writeFilePromise('heap.pb.gz', buf);
await promises.writeFile('heap.pb.gz', buf);
}

async function collectAndSaveProfiles(): Promise<void> {
Expand Down
16 changes: 6 additions & 10 deletions system-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TESTDIR=$(mktemp -d)
cp -r "$BENCHDIR" "$TESTDIR/busybench"
cd "$TESTDIR/busybench"

retry npm_install pify @types/pify typescript gts @types/node >/dev/null
retry npm_install typescript gts @types/node >/dev/null
retry npm_install --nodedir="$NODEDIR" \
$([ -z "$BINARY_HOST" ] && echo "--build-from-source=pprof" \
|| echo "--pprof_binary_host_mirror=$BINARY_HOST")\
Expand All @@ -59,18 +59,14 @@ node -v
node --trace-warnings "$BENCHPATH" 10 $VERIFY_TIME_LINE_NUMBERS

if [[ "$VERIFY_TIME_LINE_NUMBERS" == "true" ]]; then
pprof -lines -top -nodecount=2 time.pb.gz
pprof -lines -top -nodecount=2 time.pb.gz | \
grep "busyLoop.*src/busybench.js:3[3-5]"
pprof -filefunctions -top -nodecount=2 heap.pb.gz
pprof -filefunctions -top -nodecount=2 heap.pb.gz | \
pprof -lines -top -nodecount=2 time.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.js:[2-3][08-9]"
pprof -filefunctions -top -nodecount=2 heap.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.js"
else
pprof -filefunctions -top -nodecount=2 time.pb.gz
pprof -filefunctions -top -nodecount=2 time.pb.gz | \
pprof -filefunctions -top -nodecount=2 time.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.ts"
pprof -filefunctions -top -nodecount=2 heap.pb.gz
pprof -filefunctions -top -nodecount=2 heap.pb.gz | \
pprof -filefunctions -top -nodecount=2 heap.pb.gz | tee $tty | \
grep "busyLoop.*src/busybench.ts"
fi

Expand Down