-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable WASM for HdrHistogramJS (#283)
- Loading branch information
1 parent
10fa41d
commit fd09f49
Showing
2 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
const test = require('tap').test | ||
const run = require('../../lib/run') | ||
const helper = require('../helper') | ||
|
||
test('should clean up HdrHistogram WASM memory at each run', async (t) => { | ||
const server = helper.startServer() | ||
const runTwentyTimes = (resolve, reject, numberOfRuns = 0) => { | ||
run({ | ||
url: 'http://localhost:' + server.address().port, | ||
connections: 1, | ||
amount: 1 | ||
}, (result) => { | ||
// should get error " url or socketPath option required" | ||
// we can ignore this error, we just want run() to execute | ||
// and to instantiate new WASM histograms | ||
if (numberOfRuns < 20) { | ||
runTwentyTimes(resolve, reject, ++numberOfRuns) | ||
} else { | ||
resolve() | ||
} | ||
}) | ||
} | ||
const lotsOfRuns = [] | ||
for (let index = 0; index < 50; index++) { | ||
lotsOfRuns.push(new Promise(runTwentyTimes)) | ||
} | ||
|
||
await Promise.all(lotsOfRuns) | ||
|
||
// if the process has not crashed, we are good \o/ | ||
t.end() | ||
}) |