Created
          May 13, 2021 11:21 
        
      - 
      
- 
        Save nschloe/7e4cb61dd391b4edbeb10d23038aa98e to your computer and use it in GitHub Desktop. 
    numpy division vs multiplication
  
        
  
    
      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 perfplot | |
| import numpy as np | |
| def div(ab): | |
| a, b = ab | |
| return a / b | |
| def mul(ab): | |
| a, b = ab | |
| return a * b | |
| b = perfplot.bench( | |
| setup=lambda n: np.random.rand(2, n), | |
| kernels=[div, mul], | |
| n_range=[2 ** k for k in range(23)], | |
| equality_check=None | |
| ) | |
| b.save("out.png") | |
| b.show() | 
      
      
  Author
  
  
        
      
            nschloe
  
      
      
      commented 
        May 13, 2021 
      
    
  

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