Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

sequencial algorithm is faster than parallel map #240

Open
@ccknaus

Description

@ccknaus

Good evening.

I tried to compare a simple sequencial vs. parallel algorithm. To my surprise, the sequiencial code seems to be faster with different maxWorker options, as well as number of ELEMENTS. My tests are not only restricted for this simple example, but for every comparision of different functions as well.

What am I doing wrong?
What is the cause of the higher latency in the parallel map?
can I increase the speed?

const ELEMENTS = 10000;options = {    evalPath: undefined,    maxWorkers: 4,    synchronous: false};const arr = new Array(ELEMENTS).fill().map(Math.random);// Sequencial Algorithmconst start = performance.now();arr.map(number => number * 7);console.log(performance.now()-start); // about 1 ms on my machine// Parallel Alogorithmconst start2 = performance.now();var Parallel = require('paralleljs');var p = new Parallel(arr, options);log = function () {     console.log(performance.now()-start2); // about 360 up to 420 ms on my machine, depending on maxWorkers};p.map(number => number * 7).then(log);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp