Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules
proto/
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@types/tmp": "0.2.0",
"codecov": "^3.0.0",
"deep-copy": "^1.4.2",
"gts": "^1.0.0",
"gts": "^2.0.0",
"js-green-licenses": "^2.0.0",
"linkinator": "^2.0.0",
"mocha": "^8.0.0",
Expand Down
19 changes: 14 additions & 5 deletions system-test/busybench-js/src/busybench.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ function benchmark(durationSeconds) {
busyLoop(durationSeconds);
}

async function collectAndSaveTimeProfile(durationSeconds, sourceMapper,
lineNumbers) {
async function collectAndSaveTimeProfile(
durationSeconds,
sourceMapper,
lineNumbers
) {
const profile = await pprof.time.profile({
durationMillis: 1000 * durationSeconds,
lineNumbers: lineNumbers,
Expand All @@ -64,13 +67,19 @@ async function collectAndSaveHeapProfile(sourceMapper) {
}

async function collectAndSaveProfiles(collectLineNumberTimeProfile) {
const sourceMapper = await pprof.SourceMapper.create([process.cwd()]);
const sourceMapper = await pprof.SourceMapper.create([process.cwd()]);
collectAndSaveHeapProfile(sourceMapper);
collectAndSaveTimeProfile(durationSeconds/2, sourceMapper, collectLineNumberTimeProfile);
collectAndSaveTimeProfile(
durationSeconds / 2,
sourceMapper,
collectLineNumberTimeProfile
);
}

const durationSeconds = Number(process.argv.length > 2 ? process.argv[2] : 30);
const collectLineNumberTimeProfile = Boolean(process.argv.length > 3 ? process.argv[3] : false);
const collectLineNumberTimeProfile = Boolean(
process.argv.length > 3 ? process.argv[3] : false
);

pprof.heap.start(512 * 1024, 64);
benchmark(durationSeconds);
Expand Down
19 changes: 12 additions & 7 deletions system-test/busybench/src/busybench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

import {writeFile} from 'fs';
import { writeFile } from 'fs';
import * as pify from 'pify';
import {encode, heap, SourceMapper, time} from 'pprof';
import { encode, heap, SourceMapper, time } from 'pprof';

const writeFilePromise = pify(writeFile);

Expand Down Expand Up @@ -47,15 +47,20 @@ function benchmark(durationSeconds: number) {
}

async function collectAndSaveTimeProfile(
durationSeconds: number, sourceMapper: SourceMapper): Promise<void> {
const profile = await time.profile(
{durationMillis: 1000 * durationSeconds, sourceMapper});
durationSeconds: number,
sourceMapper: SourceMapper
): Promise<void> {
const profile = await time.profile({
durationMillis: 1000 * durationSeconds,
sourceMapper,
});
const buf = await encode(profile);
await writeFilePromise('time.pb.gz', buf);
}

async function collectAndSaveHeapProfile(sourceMapper: SourceMapper):
Promise<void> {
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);
Expand Down
4 changes: 2 additions & 2 deletions ts/src/sourcemapper/sourcemapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class SourceMapper {
for (const dir of searchDirs) {
try {
const mf = await getMapFiles(dir);
mf.forEach(mapFile => {
mf.forEach((mapFile) => {
mapFiles.push(path.resolve(dir, mapFile));
});
} catch (e) {
Expand Down Expand Up @@ -224,7 +224,7 @@ export class SourceMapper {
async function createFromMapFiles(mapFiles: string[]): Promise<SourceMapper> {
const limit = pLimit(CONCURRENCY);
const mapper = new SourceMapper();
const promises: Array<Promise<void>> = mapFiles.map(mapPath =>
const promises: Array<Promise<void>> = mapFiles.map((mapPath) =>
limit(() => processSourceMap(mapper.infoMap, mapPath))
);
try {
Expand Down
4 changes: 2 additions & 2 deletions ts/test/test-time-profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Time Profiler', () => {

describe('profile (w/ stubs)', () => {
// tslint:disable-next-line: no-any
const sinonStubs: Array<sinon.SinonStub<any, any>> = new Array();
const sinonStubs: Array<sinon.SinonStub<any, any>> = [];
before(() => {
sinonStubs.push(sinon.stub(v8TimeProfiler, 'startProfiling'));
sinonStubs.push(
Expand All @@ -55,7 +55,7 @@ describe('Time Profiler', () => {
});

after(() => {
sinonStubs.forEach(stub => {
sinonStubs.forEach((stub) => {
stub.restore();
});
});
Expand Down
11 changes: 4 additions & 7 deletions ts/third_party/cloud-debug-nodejs/src/agent/io/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class ScanResultsImpl implements ScanResults {
// ensure the base directory has only a single trailing path separator
baseDir = path.normalize(baseDir + path.sep);
return Object.keys(this.stats)
.filter(file => {
.filter((file) => {
return file && regex.test(file);
})
.map(file => {
.map((file) => {
return path.normalize(file).replace(baseDir, '');
});
}
Expand Down Expand Up @@ -152,10 +152,7 @@ function computeStats(
// Sort the hashes to get a deterministic order as the files may
// not be in the same order each time we scan the disk.
const buffer = hashes.sort().join();
const sha1 = crypto
.createHash('sha1')
.update(buffer)
.digest('hex');
const sha1 = crypto.createHash('sha1').update(buffer).digest('hex');
hash = 'SHA1-' + sha1;
}
resolve(new ScanResultsImpl(statistics, errors, hash));
Expand Down Expand Up @@ -224,7 +221,7 @@ function statsForFile(
): Promise<FileStats> {
return new Promise<FileStats>((resolve, reject) => {
const reader = fs.createReadStream(filename);
reader.on('error', err => {
reader.on('error', (err) => {
reject(err);
});
reader.on('open', () => {
Expand Down