dssim性能提升-2.1

针对proxy的性能提升

  1. 上周看了个书的一部分《利用python进行数据分析》,里面有讲numpy和python代码优化的一些东西
  2. 上次提到的collect_input_data本身的优化
        def collect_input_data(self):
         """Fetches input data and turns it into key-value pair for a system. """
         input_data = {}
         if self.system_type == "in":
             input_data['input'] = self.model.runtime.input_data[self.name]
             return input_data
    
         for name, connection in self.runtime_input_conns.items():
             #if name == "null": 
             #    continue
             #source_proxy = connection.get_source_proxy()
             #source_port_name = connection.get_source_port_name()
             source_proxy,source_port_name = connection.get_source_proxy_and_port_name() #合并成了
             try:
                 input_data[name] = source_proxy.emit_output_data()[source_port_name]
             except KeyError:
                 #input_data[name] = np.at_least(0)
                 input_data[name] = np.array([[0]])
    
         return input_data
    
    做了一点改变,对name=="null"的判断去掉,对connection的两个函数合并, np.at_least(0)替换为更快的np.array([[0]])
  3. 整体性能变化不大,而且scalene测试时多次测试的结果本身也有误差,不是大的提升不太好看出来结果。总时间300s的话,会有20s左右误差。

本文章使用limfx的vscode插件快速发布