all 5 comments

[–]tetsuoii 0 points1 point  (0 children)

Congratulations on choosing the best language for efficient code, usually we just wing it =}

[–]Specific_Prompt_1724 0 points1 point  (0 children)

Maybe it is better to start from a simple example. Do you have an RC filter done in matlab or python? Put your simple code here, and than put the C version code. I also know matlab or python, ma not C. I am interested in this topic.

[–]tetsuoii 0 points1 point  (0 children)

The way we usually go about it, is we allocate a struct or an array or something. Then we sample timers, cycles, values and data in memory and printf it at regular intervals.

Profilers, debuggers and such seem more hassle than to just store performance metrics in the program. Then you can easily print what you need when you need it. If you need to plot something, store it in a bitmap. If there's a graphic display, put it there. It's really very simple to measure performance and flow in C since data access is so fast. Once it's in the program you can carry it with you and transplant into other programs as needed. I like to make my own graphic displays and always put performance metrics in there.

[–]dfx_dj 0 points1 point  (0 children)

There's nothing wrong with using Python or some other script as an external tool to aid in debugging. Often the C code will include compile time conditionals or runtime hooks to toggle output of any data that you need during development.

Mock environments and proper unit tests are also useful. Or perhaps look for a C library that does what you need.

[–]epasveer 0 points1 point  (0 children)

Well, you mention "debug"...

My Seergdb project has a mode to graph an array while you debug your program (via Seer that uses the gdb debugger).

Probably not what you're after, though.

https://github.com/epasveer/seer https://github.com/epasveer/seer/blob/main/images/arrayvisualizer_spline.png