Cypress技术论坛
直播中

王若鸿

7年用户 221经验值
私信 关注
[问答]

如何在Creator中对开发的c代码进行单元测试?

你好,
我用PSoc Creator开发了C代码,我想知道如何测试开发代码的性能。

以上来自于百度翻译


     以下为原文
  Hello,

I have developed c code by using PSoc Creator and i want to know about how to test performance of developed code.

回帖(3)

姜钰

2019-1-8 14:23:53
你想做一个单元测试(如在“测试正确性”)或一个性能测试(如“它有多快”)?对于前者,我可以推荐Ceedling、CMOKK和Unity的组合。请注意,尤其是嘲讽可能是有趣的,因为您需要从硬件中抽象出来。

以上来自于百度翻译


     以下为原文
  Do you want to do a unit-test (as in 'testing for correctness') or a performance test (as in 'how fast is it')? For the former, I can recommend the combination of Ceedling, CMock and Unity. Note that especially mocking can be interesting since you need to abstract from your hardware.
举报

王琳

2019-1-8 14:38:02
对于第二种情况(如何快速…)使用逻辑分析仪,并切换一个引脚,看看事情进展得多么快……
鲍勃

以上来自于百度翻译


     以下为原文
  And for the second case (how fast...) use a logic analyzer and toggle a pin to see how fast things go on...
 
Bob
举报

张琳

2019-1-8 14:52:47
您可以使用自定义秒表组件(附加)来测量某些代码消耗的CPU时钟周期。它使用系统SyBIT定时器来计算CPU周期。该组件未完成,但适用于PSoC4、4M和5LP。要测量CPU时钟,请在代码中放置StaseWistBoad Stor()和StaseWistFixStor(),并在终端上打印结果:
StaseWistBoad启动();/重置定时器
/你的代码在这里(函数,ISR等)

停止计时()
UTIT32总线锁=停止表周期;//读取结果
要将秒表组件添加到项目中,请将其从附件演示项目导入。
停止手表P4MY001.PNG
70.4 K
停止手表P4MY01A.PNG
49.1 K
TopWistApP4MY01-1000.CyWrk.SaveV01.Zip
1.4兆字节

以上来自于百度翻译


     以下为原文
  You can measure amount of CPU clock cycles consumed by some piece of code using custom StopWatch component (attached). It uses system SysTick timer to count CPU cycles. The component is rather unfinished, but works for PSoC4, 4M and 5LP. To measure CPU clocks put StopWatch_Start() and StopWatch_Stop() in your code, and print result on terminal:
 
StopWatch_Start() ; // reset timer
// your code is here (function, ISR, etc.)
.....
StopWatch_Stop() ; // stop timer
 
uint32 BusClockTicks = StopWatch_Cycles; // read result
 
To add StopWatch component to you project, Import it from the demo project attached.




举报

更多回帖

发帖
×
20
完善资料,
赚取积分