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

增加XML转换的快速模式,发送请求以及组装响应对象的时候,不再依赖java的反射机制。 #1390

Merged
merged 7 commits into from
Jan 28, 2020

Conversation

outersky
Copy link

目的:
1:可以通过 graalvm 生成native image.
2:提升性能

参见XmlConfig.java中的说明:

public class XmlConfig {

  /**
   * 是否使用快速模式
   *
   * 如果设置为true,将会影响下面的方法,不再使用反射的方法来进行xml转换。
   * 1: BaseWxPayRequest的toXML方法
   * 2: BaseWxPayResult的fromXML方法
   * @see com.github.binarywang.wxpay.bean.request.BaseWxPayRequest#toXML
   * @see com.github.binarywang.wxpay.bean.result.BaseWxPayResult#fromXML
   *
   * 启用快速模式后,将能:
   * 1:性能提升约 10 ~ 15倍
   * 2:可以通过 graalvm 生成native image,大大减少系统开销(CPU,RAM),加快应用启动速度(亚秒级),加快系统部署速度(脱离JRE).
   *
   * 参考测试案例: com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResultTest#benchmark
   * 参考网址: https://www.graalvm.org/
   */
  public static boolean fastMode = false;

}

主体功能已经完成改造,剩余notify 下面2个子类需要特殊处理。
另外,测试是个问题,1:本身现在项目中的测试案例不多;2:所有业务场景的模拟数据缺失,不易进行XML双向转换的测试。

改动比较多,希望能大家一起测试。

@binarywang
Copy link
Member

都改造完了吗?

@outersky
Copy link
Author

经过改造,现在已经利用graalvm生成native-image
效果见这个demo项目

@outersky
Copy link
Author

都改造完了吗?

全部完成了,有时间了把所有的XML解析补充一下测试案例。

@binarywang
Copy link
Member

感谢,先合并代码了,你测试没问题就好,毕竟不改变原有代码行为。

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

Successfully merging this pull request may close these issues.

2 participants