Created
          May 14, 2021 14:05 
        
      - 
      
- 
        Save nschloe/d093057ef912faf1c1636b394e5bf412 to your computer and use it in GitHub Desktop. 
    np.dot vs blas.ddot
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import numpy as np | |
| import perfplot | |
| from scipy.linalg.blas import ddot | |
| def np_dot(data): | |
| x, y = data | |
| return np.dot(x, y) | |
| def sp_ddot(data): | |
| x, y = data | |
| return ddot(x, y) | |
| b = perfplot.bench( | |
| setup=lambda n: np.random.rand(2, n), | |
| kernels=[np_dot, sp_ddot], | |
| n_range=[2 ** k for k in range(24)], | |
| ) | |
| b.save("out.png") | |
| b.show() | 
      
      
  Author
  
  
        
      
            nschloe
  
      
      
      commented 
        May 14, 2021 
      
    
  

  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment