How to calculate the FLOPS of a Python program?

717 Views Asked by At

I have the following python program for Linear Search algorithm:

import numpy as np

a, item = [2.6778716682529704, 8.224004328108661, 8.819020166860604, 25.04500044837642, 
114.6788167136755, 147.21744952331062, 109.1213882924877, 123.36405515780437, 10.113059020720906, 
59.01217380179232, 97.07159649653909, 9.010298414811622, 18.749094869496762, 75.27074394937102, 
85.75441597903486, 67.06650469807076, 59.193039503175825, 53.617565239895384, 13.945783254008596, 
130.41570895088282, 47.71407473246193, 51.903813982574384, 102.21910956684476, 106.99206485108651, 
80.95491815609066, 128.1883746500615, 29.40146119124661, 36.67058053312906, 124.22796860099373, 
46.14312646522846, 88.17789802786112, 10.952449565320403, 109.91937529687375, 124.20305335555281, 
12.389516472883905, 123.44886155581098, 17.421503974572637, 56.70857063455636, 71.00168946472502, 
103.07336370249966, 133.12218972160733, 88.57270183072094, 62.44720049852278, 19.689835681780934, 
57.274235858675404, 11.4949075513903, 32.06572223098081, 16.85725643503054, 147.75304767222545, 
73.03273121662845], 73.03273121662845

# Want to compute the Flops for the below 'for' loop
for i in range(50):
    if a[i] == item:
        print("item found")

I have the following questions:

  1. Since the above program lacks any basic floating point operations (such as +, -, *, /) and only has a comparison (relational) operator (==), should there be any Flops defined for the above linear search program?
  2. Regarding 1), if Flops should not be undefined then what should be the Flops of the for loop written in the above program?

I tried exploring PyPI to seek if any python package can be used to compute the Flops for the above program but found none. Moreover, attempted to find any solution for this, however, had no great fate in this regard.

0

There are 0 best solutions below