c# - 编译表达式的性能
问题描述
我有以下方法并对编译表达式的性能影响感到好奇。
public async Task<Response<TResult>> Execute<TApi, TResult>(Expression<Func<TApi, Task<TResult>>> executeApiMethod)
{
try
{
var responseData = await executeApiMethod.Compile()(restApi).ConfigureAwait(false);
return new Response<TResult>(responseData);
}
catch (ApiException refitApiException)
{
throw;
}
}
有没有更好的办法?是否有任何性能影响compile()
,因为这是通用的,并且每次运行 compile 时都可能使用不同的参数调用是 scavy。
解决方案
推荐阅读
- spring - 使用 Spring Cloud 连接器和 HikariCP 配置 Postgresql sslrootcert
- python - 我们可以在 kivy 中使用 matplotlib.animation 吗?如果是,如何?
- javascript - 当我从另一个函数内部调用它时,函数一直返回 0
- jolie - 使用 Jolie 存储工作流状态
- linux - 如何在mongodb中将数据库从一台服务器复制到另一台服务器
- json - 如何在 couchbase 数组中搜索特定字符串
- xml - XSLT 的 document() 函数的 TWIG 等价物是什么?
- c++ - 如果从使用 Poco/Timer 启动的线程进行日志记录,则 Poco HTTPServer 中止
- java - 我可以在我的 java 应用程序上为 config.yml 指定默认值吗?
- node.js - db.createRole 与 Mongoose