• 一段测试try...catch运行时间的代码


    public class Test2 {

        private static int test() {
            int i=1;

            try {
                i=2;
                return i;
            } catch (Exception e) {
                i = 3;
                return i;
            } finally {
                i = 4;
                System.out.println(i);
            }
           
        }

        public static void main(String[] args){
         double b = 0;
         String s = "";
         long ii = System.currentTimeMillis();
            for(int i = 0; i<20000;i++) {
             try {
              b = StrictMath.pow(b+i, 1.0/3);
              s = s + b+";";
             }catch(Exception e){
              e.printStackTrace();
             }finally {

             }
            }
           
            //System.out.println("b = "+b + " s = "+ s);
            System.out.println(System.currentTimeMillis()-ii);
           
         double c = 0;
         String ss = "";
         long iii = System.currentTimeMillis();
            for(int i = 0; i<20000;i++) {
              c = StrictMath.pow(c+i, 1.0/3);
              ss = ss + c+";";
            }
           
            //System.out.println("b = "+c + " ss = "+ ss);
            System.out.println(System.currentTimeMillis()-iii);
           
        }
    }

  • 相关阅读:
    conda更换为清华镜像源
    NVDIA的GPU驱动升级
    Windows使用nvidia-smi查看GPU信息
    查询GPU是否支持CUDA
    PyTorch教程【一】Pytorch环境的配置及安装
    JAVA基础篇—继承
    SQL
    随机数
    hdu 4751 Divide Groups 二分图
    hdu 4126 Genghis Khan the Conqueror hdu 4756 Install Air Conditioning 最小生成树
  • 原文地址:https://www.cnblogs.com/flying607/p/3416015.html
Copyright © 2020-2023  润新知