Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Measure of code time in C-Script

0 votes
56 views
Hello.

I would like to know how to measure the time period between 2 point in the update code in the block C-Script. The command CurrentTime() just gives the time at the start of the period.

I need this to compare 2 different codes and tell which one is faster. Thanks.
asked Oct 29 by Seyager (17 points)

1 Answer

0 votes
The answer to this question does not really have anything to do with PLECS. The correct measurement of execution time in a multitasking system is quite complex and highly operating system dependent. The most reliable method is to use performance counters in the CPU, making sure that the measured thread is only executed on a single CPU core. Google "measure code performance in C" to get some hints. Whether these algorithms can be implemented in a C script is another matter.

The attached model measures the wall clock time between the start and end of a simulation. It can serve as an estimate of performance.
answered Nov 15 by Oliver Schwartz (545 points)
...