Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
worker-nodes big data transfer performance
$ node test_server.js
simple: 337.425ms
simple2: 1.971ms
big data: 3385.748ms
big data stringify: 801.013ms
big string: 565.437ms
module.exports = function(data, parse) {
if (parse) {
const result = JSON.parse(data);
return result[0][0];
}
return false;
};
const workerNodes = require("worker-nodes");
const renderWorkers = new workerNodes(`${__dirname}/test_render.js`, {
maxWorkers: 1,
autoStart: true,
});
console.time("simple");
renderWorkers.call(true).then((result) => {
console.timeEnd("simple");
console.time("simple2");
renderWorkers.call(true).then((result) => {
console.timeEnd("simple2");
const bigData = [];
for (let i = 0; i < 1000; i += 1) {
const a = [];
for (let j = 0; j < 1000; j += 1) {
a.push(j);
}
bigData.push(a);
}
console.time("big data");
renderWorkers.call(bigData).then((result) => {
console.timeEnd("big data");
console.time("big data stringify");
renderWorkers.call(JSON.stringify(bigData), true).then((result) => {
console.timeEnd("big data stringify");
let bigString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (let i = 0; i < 17; i += 1) {
bigString += bigString;
}
console.time("big string");
renderWorkers.call(bigString).then((result) => {
console.timeEnd("big string");
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.