java对UnderStand工具集成

1.本地安装UnderStand工具
2.用java代码调用cmd命令执行 并产生报告
3.UnderStand的cmd命令
und create -languages c++ c:\myDb.udb
und add c:\目录或者文件夹 c:\myDb.udb
und analyze -all c:\myDb.udb
报告:
und report c:\myDb.udb
4.代码如下:
/**

  • @author hxsi

  • @date 2021年06月16日 14:08
    /
    @Service
    @Slf4j
    public class UnderStandServiceExt extends OpenStackService {
    /
    *

    • 环境里面underStand位置
      /
      @Value(value = “${testtool.underStand}”)
      public String underStand;
      /
      *
    • 文件保存位置
      */
      @Value(value = “${testtool.pathJmx}”)
      public String pathJmx;

    /**

    • UnderStand 测试工具
    • @param path 测试文件地址
    • @return true
      */
      public String getUnderStand(String path) throws IOException {
      String osName = System.getProperties().getProperty(CommonConstant.OS_NAME).toLowerCase();
      SimpleDateFormat sdf = new SimpleDateFormat(CommonConstant.Y_M_D);
      String dateNowStr = sdf.format(new Date());
      //报告保存位置
      String underStandPath = null;
      if (osName.contains(CommonConstant.WINDOWS)) {
      underStandPath = pathJmx + dateNowStr + CommonConstant.SYMBOL +CommonConstant.UNDER_STAND + dateNowStr;
      }else {
      underStandPath = CommonConstant.HOME + dateNowStr + CommonConstant.SYMBOL + CommonConstant.UNDER_STAND + dateNowStr;
      }
      //判断文件是否存在
      File fileJmx = null;
      if (osName.contains(CommonConstant.WINDOWS)) {
      fileJmx = new File(pathJmx + dateNowStr + CommonConstant.SYMBOL +CommonConstant.UNDER_STAND + dateNowStr);
      }else {
      fileJmx = new File(CommonConstant.HOME + dateNowStr + CommonConstant.SYMBOL + CommonConstant.UNDER_STAND + dateNowStr);
      }
      if (fileJmx.exists()){
      //有文件就删除
      Boolean result = FileUtil.delFiles(fileJmx);
      if (!result){
      log.error(“文件删除失败”);
      return null;
      }
      }
      File file = new File(underStandPath);
      if(!file.exists()){
      file.mkdirs();
      }
      file.createNewFile();
      //执行cmd 命令
      Runtime.getRuntime().exec(CommonConstant.CMD_EXE_START + CommonConstant.UND_CREATE + underStandPath + CommonConstant.SYMBOL + CommonConstant.MYDB_UDB,null,
      new File(underStand));
      Runtime.getRuntime().exec(CommonConstant.CMD_EXE_START + CommonConstant.UND_ADD + path + underStandPath + CommonConstant.SYMBOL + CommonConstant.MYDB_UDB,null,
      new File(underStand));
      Runtime.getRuntime().exec(CommonConstant.CMD_EXE_START + CommonConstant.UND_ANALYZE + underStandPath + CommonConstant.SYMBOL + CommonConstant.MYDB_UDB,null,
      new File(underStand));
      Runtime.getRuntime().exec(CommonConstant.CMD_EXE_START + CommonConstant.UND_REPORT + underStandPath + CommonConstant.SYMBOL + CommonConstant.MYDB_UDB,null,
      new File(underStand));
      return underStandPath;
      }
      }

里面的常量都在jmeter文章里面

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Understand工具是Scientific Toolworks Understand的简称,是一款源代码阅读分析软件。使用Understand可以提高代码阅读效率,并具有架构分析、代码评审与度量、生成软件质量统计与报表等功能。\[1\]相比于其他类似的软件,Understand在功能和使用方法上更加方便,可以帮助用户查看函数调用关系图,提供直观的代码分析体验。\[2\]要使用Understand软件,需要先进行下载安装并进行破解,具体的安装过程可以在网上找到相关教程。安装完成后,打开软件,需要先建立一个工程才能查看代码,不能像vscode那样直接将文件夹拖入软件界面中打开。\[3\] #### 引用[.reference_title] - *1* [Understand工具可以计算哪些度量指标](https://blog.csdn.net/qq_41528502/article/details/128362783)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [嵌入式代码查看分析利器---Understand](https://blog.csdn.net/qq_20222919/article/details/130438668)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

司小白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值