C#和java的异常处理性能对比
刚刚接触C#,据说C#的异常处理很耗费性能。
于是来做个测试。
public class Test {public static void main(String[] args) {long start = System.currentTimeMillis();for(int i=0; i<1000; i++){try{Integer.parseInt(null);}catch(Exception e){}}System.out.println(System.currentTimeMillis()-start);}}输出结果为:
2
差距也够大的!看来姜还是老的辣啊,微软优化的还不够……