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

使用 log 库的宏打印日志与使用 tklog 中的宏异步打印日志会有什么区别么 #7

Open
Tianion opened this issue Aug 30, 2024 · 1 comment

Comments

@Tianion
Copy link

Tianion commented Aug 30, 2024

RT,这中间会有什么性能损耗么

@donnie4w
Copy link
Owner

@Tianion
两者没有区别
通过tklog中设置 ASYNC_LOG.uselog() 来启用标准库API,实际上是把标准库的执行实例设置为 异步对象 ASYNC_LOG
它们差异非常小,可以认为没有差别。

它们的大概的差别是:
标准库会多几条判断指令;另外标准库会将一些参数事先获取。文件名行号等。如果你设置的日志库格式没有文件名行号,那么直接调tklog宏,比如tklog::async_debug! 则不会获取这些参数。但调用 log::debug!时,标准库还是会先获取这些参数,传递给tklog。 但是这些差异对性能影响非常小,即使高并发场景也不会表现出明显的性能差异。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants