Skip to content

Slow when looping thrugh a big array #13

Description

@Sivaranjith1

I am trying to create an app which runs in real time, but when I test it the array looping is so slow it is not usable

const ffi = require('ffi-napi');
const ref = require('ref-napi');
const ArrayType = require('ref-array-di')(ref);

const int = ref.types.int;
const IntArray = ArrayType(int);

let arr = new IntArray(1280*1080*3)

console.time('time')
for (let i = 0; i < arr.length; i++) {
		const element = arr[i];
	}
console.timeEnd("time")

This takes 3394ms to loop through. Do anyone know how to fix this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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