Skip to content
Open
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
10 changes: 6 additions & 4 deletions cpuprofilenode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

func TestCPUProfileNode(t *testing.T) {
// CPU profiles are sampling based. Running this test alongside the rest of
// the package can starve the profiler long enough for short-lived call
// paths to be absent from the profile.
// the package can starve the profiler, so keep it serial and give every
// expected call path one continuous sampling window.

ctx := v8.NewContext(nil)
iso := ctx.Isolate()
Expand All @@ -32,9 +32,11 @@ func TestCPUProfileNode(t *testing.T) {
fatalIf(t, err)
fn, err := val.AsFunction()
fatalIf(t, err)
timeout, err := v8.NewValue(iso, int32(1000))
timeout, err := v8.NewValue(iso, int32(0))
fatalIf(t, err)
_, err = fn.Call(ctx.Global(), timeout)
pathDuration, err := v8.NewValue(iso, int32(250))
fatalIf(t, err)
_, err = fn.Call(ctx.Global(), timeout, pathDuration)
fatalIf(t, err)

cpuProfile := cpuProfiler.StopProfiling(title)
Expand Down
20 changes: 10 additions & 10 deletions cpuprofiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ const profileScript = `function loop(timeout) {
}
}
}
function delay() { try { loop(10); } catch(e) { } }
function bar() { delay(); }
function baz() { delay(); }
function foo() {
function delay(timeout = 10) { try { loop(timeout); } catch(e) { } }
function bar(timeout) { delay(timeout); }
function baz(timeout) { delay(timeout); }
function foo(delayTimeout = 10) {
try {
delay();
bar();
delay();
baz();
delay(delayTimeout);
bar(delayTimeout);
delay(delayTimeout);
baz(delayTimeout);
} catch (e) { }
}
function start(timeout) {
function start(timeout, delayTimeout = 10) {
var start = Date.now();
do {
foo();
foo(delayTimeout);
var duration = Date.now() - start;
} while (duration < timeout);
return duration;
Expand Down
Loading