Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
907 bytes
|
Line | |
---|
1 | import Piscina from '..';
|
---|
2 | import { resolve } from 'path';
|
---|
3 | import { test } from 'tap';
|
---|
4 |
|
---|
5 | test('can set niceness for threads on Linux', {
|
---|
6 | skip: process.platform !== 'linux'
|
---|
7 | }, async ({ equal }) => {
|
---|
8 | const worker = new Piscina({
|
---|
9 | filename: resolve(__dirname, 'fixtures/eval.js'),
|
---|
10 | niceIncrement: 5
|
---|
11 | });
|
---|
12 |
|
---|
13 | // ts-ignore because the dependency is not installed on Windows.
|
---|
14 | // @ts-ignore
|
---|
15 | const currentNiceness = (await import('nice-napi')).default(0);
|
---|
16 | const result = await worker.runTask('require("nice-napi")()');
|
---|
17 |
|
---|
18 | // niceness is capped to 19 on Linux.
|
---|
19 | const expected = Math.min(currentNiceness + 5, 19);
|
---|
20 | equal(result, expected);
|
---|
21 | });
|
---|
22 |
|
---|
23 | test('setting niceness never does anything bad', async ({ equal }) => {
|
---|
24 | const worker = new Piscina({
|
---|
25 | filename: resolve(__dirname, 'fixtures/eval.js'),
|
---|
26 | niceIncrement: 5
|
---|
27 | });
|
---|
28 |
|
---|
29 | const result = await worker.runTask('42');
|
---|
30 | equal(result, 42);
|
---|
31 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.