07-25-2023 03:04 AM
Hello,
i have one question regarding logging parameters in file.
When spreadsheet is used for logging, then application use CPU less then 1%, and i'm staisfied with that.
But in case that i log same ammount of data, at same sampling rate with tdms, then CPU usage is 10% or more.
Now question is why TDMS use much more cpu, i thoughts that tdms is more efficient then any other method.
Is anyone can advice how to reduce cpu usage?
Sampling rate is same by spreedsheet and by tdms.
Thanks
07-25-2023 04:24 AM
This is just a subVI and we cannot tell how you are measuring. Is the loop rate of the caller the same in both cases? (Maybe it runs much faster in the tdms case?)
Please attach some code and a simple testing caller that simulates typical data.
07-25-2023 04:33 AM
Thanks for fast reply.
loop rate is the same (50ms). Just in case structure is chosen between tdms or spreadsheet.
I noticed that root cause could be that i tested in development enviroment, but when app is created, then cpu percentage is much less.
Additional question is when i put to log values every 100ms, then i have only 6 logs per second in file, and not 10.
But it is probably because complete iteration in loop take more time, then 100ms.
07-25-2023 06:42 AM
You are being lied to by your benchmark.
Essentially, the spreadsheet file is already defragmented and TDMS Files are written fragmented. So, when you ask to get the file size..... oh, yeah 😶 the TDMS File needs to be defragmented and that takes CPU resources.
07-25-2023 06:48 AM
TDMS is not really made for streaming strings. It is highly optimized for raw numeric data. So that could be causing issues as well.
If you are just writing strings, use a text file.
07-25-2023 08:45 AM - edited 07-25-2023 08:49 AM
@crossrulz wrote:If you are just writing strings, use a text file.
.. and use low-level file functions. Open the file at program start, append your strings and increment a separate size counter, then close the file at the end.
"Write to delimited spreadsheet" opens and closes the file with each call, requiring much more effort!
And yes, the slowest component determines the loop rate, so if you are only getting 6 instead of 10 entries, all bets are off. (Was that text, tdms, or both?).