sync-rpc 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/index.test.js +19 -0
- package/lib/index.js +6 -1
- package/package.json +1 -1
|
@@ -22,3 +22,22 @@ rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
+
rpc.FUNCTION_PRIORITY.forEach((fn, i) => {
|
|
26
|
+
let longMessage = '';
|
|
27
|
+
for (let i = 0; i < 100000; i++) {
|
|
28
|
+
longMessage += 'My Long Message Content';
|
|
29
|
+
}
|
|
30
|
+
test('profile large ' + fn.name, () => {
|
|
31
|
+
try {
|
|
32
|
+
rpc.configuration.fastestFunction = fn;
|
|
33
|
+
const start = Date.now();
|
|
34
|
+
for (let i = 0; i < 10; i++) {
|
|
35
|
+
expect(client(longMessage)).toBe(`sent ${longMessage} to My Server`);
|
|
36
|
+
}
|
|
37
|
+
const end = Date.now();
|
|
38
|
+
console.log('large ' + fn.name + ': ' + (end - start));
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
console.log('large ' + fn.name + ' fails');
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -91,7 +91,12 @@ function nativeNC(port, input) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
function nodeNC(port, input) {
|
|
94
|
-
|
|
94
|
+
const src = nodeNetCatSrc(port, input);
|
|
95
|
+
if (src.length < 1000) {
|
|
96
|
+
return spawnSync(process.execPath, ['-e', src]);
|
|
97
|
+
} else {
|
|
98
|
+
return spawnSync(process.execPath, [], {input: src});
|
|
99
|
+
}
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
function test(fn, port) {
|