Forum > Linux
Improving run speed on Raspberry (clone)
gidesa:
Hello,
I have a FPC program on a Raspberry clone, called Orange PI Zero. His OS is Armbian.
Lazarus +FPC are wonderful tools to develop fast programs on SBC computers.
This program cycles continuously polling a series of I2C sensors/devices.
The cycle should be as fast as possible, in the order of few milliseconds.
My question is: could OO style programming slow execution, adding more software layers? Or can the compiler generate code as fast for OO as for procedural style?
MarkMLl:
I presume you mean a Raspberry /Pi/ clone.
Are you using a background thread to get the data? What API is it using? Are the devices on a single bus? What's the I2C clockspeed? Do the devices mandate any particular pacing? Taking those last three into consideration, can you guarantee that you can actually access the devices fast enough?
MarkMLl
gidesa:
--- Quote from: MarkMLl on November 22, 2024, 01:35:49 pm ---I presume you mean a Raspberry /Pi/ clone.
Are you using a background thread to get the data? What API is it using? Are the devices on a single bus? What's the I2C clockspeed? Do the devices mandate any particular pacing? Taking those last three into consideration, can you guarantee that you can actually access the devices fast enough?
--- End quote ---
Yes, it's a Raspberry Pi clone. A good quantity of Raspberry software can run on it.
The program is not a prototype, it's already running and accessing all devices (6) in a loop of 10 milliseconds (in theory, maybe some cycles are executed in longer time). It's in practice a cooperative scheduler, so every device is accessed at its required pace, setting appropriate cycle numbers. There is one I2C bus, should be at OS default 400 khz. Anyway there is no malfunction, all devices react as expected, then there is no strict reason to modify it.
So my question is for improving performance, not about fixing errors.
alpine:
--- Quote from: gidesa on November 22, 2024, 01:21:46 pm ---Hello,
I have a FPC program on a Raspberry clone, called Orange PI Zero. His OS is Armbian.
Lazarus +FPC are wonderful tools to develop fast programs on SBC computers.
This program cycles continuously polling a series of I2C sensors/devices.
The cycle should be as fast as possible, in the order of few milliseconds.
My question is: could OO style programming slow execution, adding more software layers? Or can the compiler generate code as fast for OO as for procedural style?
--- End quote ---
I think you should be a bit more specific in your question. The OO itself is nothing more than dragging a hidden parameter (aka Self) and an additional redirection when calling a virtual methods. Shouldn't be a big performance penalty, rather a problem would be the use of managed variables and exceptions handling.
OTOH the word 'style' in your question may refer to the improper in that case practices like RAII and the extensive use of the heap which is quite typical of the OO. But there are a remedies, though.
marcov:
Simple OO overhead is in the nanosecond realm on GHz SBCs CPUs, not in millisecond.
The problem is probably the polling or the way of polling, not the OO overhead.
Navigation
[0] Message Index
[#] Next page