Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4526

General • RAM vs. Flash performance optimization [C++]

$
0
0
Hi all

I'm new to the Pi Pico world and specialy the performance of Flash vs. RAM is strange. Upcomming from other ARM controllers, there are mostly no difference between this 2 (internal) memories regarding to the execution speed.

So there are some questions:
  • How mutch slower is the Flash than the RAM? I read somewhere that flash memory is about 40 times slower than RAM. If that's true, then I don't have to waste my time optimizing code and compiling.
  • What is the best strategy? There are several ways to optimize performance (compile mode = release, mark blocks as time-critical)...
  • If not everything can be copied to RAM due to the binary size, what is the best way to mark time-critical parts in C++ (usually these are not limited to functions but also member variables)?

Code:

// foo.hclass foo{public:std::array<int, 3> CorrecionValues;void Print();};// foo.cppstd::array<int, 3> foo::CorrectionValues = {1, 2, 3};// or ???// std::array<int, 3> __not_in_flash(foo::CorrectionValues) = {1, 2, 3};// std::array<int, 3> __scratch_x(foo::CorrectionValues) = {1, 2, 3};void foo::Print()// or ???// void __not_in_flash_func(foo::Print()){for(const auto& _val : CorrectionValues){printf("Value = "%d\r\n", _val);}}
Best regards
P51D

Statistics: Posted by P51D — Tue Apr 16, 2024 9:24 am — Replies 0 — Views 8



Viewing all articles
Browse latest Browse all 4526

Trending Articles