Skip to content

Function is 3X slower than regular JS #1184

Closed
@nischayv

Description

@nischayv

The following function is roughly 3x slower for me compared to regular js for large values. Am I doing something wrong or is there something I can do to speed it up? Any kind of help is appreciated!

function map_page_rank(pages: Array<Int32Array>, page_ranks: Float64Array, maps: Array<Float64Array>, noutlinks: Int32Array, n: i32): void {
  const t1 = performanceNow();
  for (let i=0; i < n; ++i) {
    const outbound_rank = unchecked(page_ranks[i])/unchecked(noutlinks[i]);
    for(let j=0; j < n; ++j) {
      if (unchecked(pages[i][j]) === 0) {
        unchecked(maps[i][j] = 0);
      } else {
        unchecked(maps[i][j] = unchecked(pages[i][j])*outbound_rank);
      }
    }
  }
  const t2 = performanceNow();
  consoleLog(((t2 - t1)/1000).toString());
}

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