Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【优化】测试平均时间的宏 TIME_TAST 也允许测普通 void 函数 #22

Closed
lymslive opened this issue Apr 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@lymslive
Copy link
Owner

#6 优化了测试用例底层结构后,DEF_TAST 测试用例与普通 void 函数本质上已基本相同,故原 TIME_TAST 的实现也可容易扩展到普通 void 函数。并且这样可能更方便,没必要为了测试函数运行时间而专门用 DEF_TAST 定义包装一下。

在静态扩展库中也提供了一个自由函数 tast::average_time() 来测另一个 void 函数的平均时间,参数与 TIME_TAST 相同。用 TIME_TAST 测时的函数或用例内,可用 TIME_TICTIME_TOC 缩小测时范围,也因此在一定程度上可能会影响全局的用例管理对象(尤其限制了多线程的使用)。用 average_time() 测时的函数内则不能用 TIME_TICTIME_TOC,否则必将影响全局的用例管理对象。

一般情况下,是不鼓励在被函数内使用 TIME_TICTIME_TOC 的,那是为粗略汇报用例耗时而设的。在特意跑多次测平时间的情况下,可先行把被测函数范围写小一点或准确一点。

@lymslive lymslive added the enhancement New feature or request label Apr 27, 2024
@lymslive lymslive closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant