Skip to content

Commit

Permalink
test: remove FIB environment variable from cpu-prof.js
Browse files Browse the repository at this point in the history
PR-URL: #28183
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and targos committed Jun 18, 2019
1 parent a3f8385 commit bd16f9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
5 changes: 2 additions & 3 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,9 @@ The `cpu-prof` module provides utilities related to CPU profiling tests.

### env

* Default: { ...process.env, FIB, NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER' }
* Default: { ...process.env, NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER' }

Environment variables used in profiled processes. FIB will be set to `40` on
Windows and `30` elsewhere.
Environment variables used in profiled processes.

### getCpuProfiles(dir)

Expand Down
13 changes: 1 addition & 12 deletions test/common/cpu-prof.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict';

const common = require('./');
require('./');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
Expand Down Expand Up @@ -34,23 +34,12 @@ function verifyFrames(output, file, suffix) {
assert.notDeepStrictEqual(frames, []);
}

let FIB = 30;
// This is based on emperial values - in the CI, on Windows the program
// tend to finish too fast then we won't be able to see the profiled script
// in the samples, so we need to bump the values a bit. On slower platforms
// like the Pis it could take more time to complete, we need to use a
// smaller value so the test would not time out.
if (common.isWindows) {
FIB = 40;
}

// We need to set --cpu-interval to a smaller value to make sure we can
// find our workload in the samples. 50us should be a small enough sampling
// interval for this.
const kCpuProfInterval = 50;
const env = {
...process.env,
FIB,
NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER'
};

Expand Down
9 changes: 8 additions & 1 deletion test/fixtures/workload/fibonacci.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@ function fib(n) {
return fib(n - 1) + fib(n - 2);
}

const n = parseInt(process.env.FIB) || 35;
// This is based on emperial values - in the CI, on Windows the program
// tend to finish too fast then we won't be able to see the profiled script
// in the samples, so we need to bump the values a bit. On slower platforms
// like the Pis it could take more time to complete, we need to use a
// smaller value so the test would not time out.
const FIB = process.platform === 'win32' ? 40 : 30;

const n = parseInt(process.env.FIB) || FIB;
process.stdout.write(`${fib(n)}\n`);

0 comments on commit bd16f9b

Please sign in to comment.