Open buggedcom opened 5 years ago
And even when not creating a new instance of the class it still is at 100% cpu
I just created a small sample.
Matrix.configure({'led-rows':32, 'led-cols':32});
class Sample {
constructor() {
this.matrix = new Matrix({mode:'pixel'});
this.offset = 0;
}
render() {
this.matrix.clear();
this.matrix.setPixel(this.offset % this.matrix.width, Math.floor(this.offset / this.matrix.width), this.matrix.color('red'));
this.matrix.render();
this.offset = (this.offset + 1) % (this.matrix.width * this.matrix.height);
}
run() {
setInterval(this.render.bind(this), 100);
}
};
var sample = new Sample();
sample.run();
When I run this code, node consumes about 70% cpu. Even if I set the interval to 10000 it still consumes about 70% cpu. There is a lot going on in the background to keep the matrix updated even when not drawing to it. I am using Hzellers active board. If you are using the passive board it might actually take 100% cpu...
Hmm. Running the demo's of Hzellers, even the most complex ones only top out at around 65% cpu for the process. I realise there is some extra usage because it has node on top but it seems a little extreme.
I would love to try to help debug why, but I have no C knowledge.
I agree. But right now, I don't have a good answer. Matrix.configure() only calls Hzellers Init() function and allocates some arrays matching the size of the matrix.
I do see some redundancies in my C++ code. Don't think it is the problem, but I will remove it anyway. Lesser code the better...
Have removed as much code as I could (version 1.0.72), but still at 70% cpu when running a small pixel through the matrix...
I'm using
fastify
to to create a REST server to control the operation of the board, however as you can see the node process stays at 100% even when simply invoking the base class without setting any pixels. Is this to be expected?