我有一个从数据库获取数据并发送到UI以生成图表的类。
该类的执行时间为14秒
List listOfCLI =new ArrayList();
List listOfRRV =new ArrayList();
List listOfROP =new ArrayList();
List listOfACR =new ArrayList();
List listOfPIN =new ArrayList();
List listOfRIS =new ArrayList();
List listOfTAA =new ArrayList();
List listOfTAR =new ArrayList();
List listOfPHA =new ArrayList();
List listOfSAR =new ArrayList();
List listOfGRQ =new ArrayList();
List listOfADC =new ArrayList();
当我将代码更改为
List<DataMS> listOfCLI =new ArrayList<DataMS>();
List<DataMS> listOfRRV =new ArrayList<DataMS>();
List<DataMS> listOfROP =new ArrayList<DataMS>();
List<DataMS> listOfACR =new ArrayList<DataMS>();
List<DataMS> listOfPIN =new ArrayList<DataMS>();
List<DataMS> listOfRIS =new ArrayList<DataMS>();
List<DataMS> listOfTAA =new ArrayList<DataMS>();
List<DataMS> listOfTAR =new ArrayList<DataMS>();
List<DataMS> listOfPHA =new ArrayList<DataMS>();
List<DataMS> listOfSAR =new ArrayList<DataMS>();
List<DataMS> listOfGRQ =new ArrayList<DataMS>();
List<DataMS> listOfADC =new ArrayList<DataMS>();
执行时间最多为17秒。
为什么蚀所暗示的添加通用有如此不利的影响。
您还可以建议使用泛型来减少执行时间的最佳方法吗?
**Map<String, List> reqCLI =new HashMap<String, List>();
Map<String, List> reqRRV =new HashMap<String, List>();
Map<String, List> reqROP =new HashMap<String, List>();
Map<String, List> reqACR =new HashMap<String, List>();
Map<String, List> reqPIN =new HashMap<String, List>();
Map<String, List> reqTAA =new HashMap<String, List>();
Map<String, List> reqTAR =new HashMap<String, List>();
Map<String, List> reqRIS =new HashMap<String, List>();
Map<String, List> reqPHA =new HashMap<String, List>();
Map<String, List> reqSAR =new HashMap<String, List>();
Map<String, List> reqGRQ =new HashMap<String, List>();
Map<String, List> reqADC =new HashMap<String, List>();
List<Map<String, List>> listCLI=new ArrayList<Map<String, List>>();
List<Map<String, List>> listRRV=new ArrayList<Map<String, List>>();
List<Map<String, List>> listROP=new ArrayList<Map<String, List>>();
List<Map<String, List>> listACR=new ArrayList<Map<String, List>>();
List<Map<String, List>> listPIN=new ArrayList<Map<String, List>>();
List<Map<String, List>> listTAA=new ArrayList<Map<String, List>>();
List<Map<String, List>> listTAR=new ArrayList<Map<String, List>>();
List<Map<String, List>> listRIS=new ArrayList<Map<String, List>>();
List<Map<String, List>> listPHA=new ArrayList<Map<String, List>>();
List<Map<String, List>> listSAR=new ArrayList<Map<String, List>>();
List<Map<String, List>> listGRQ=new ArrayList<Map<String, List>>();
List<Map<String, List>> listADC=new ArrayList<Map<String, List>>();**
这些是剩余的收藏品
最佳答案
由于类型擦除(请参见http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#FAQ101),泛型类型不会在已编译的字节码中表示,因此执行时的性能应该没有差异。仅在编译时检查参数化类型。