While studying algorithms and data structures I manually evaluate BigO complexity for my script. Is there a way, let say a button in any Python IDE or a package, to calculate BigO for any given function or a program?
UPDATE:
Let's say I have
def print_first_element(a):
print a[0]
why I can't write the analyzer which will say me ok you access the array (list) by index and its O(1), or
def print_all_element_of_list(a):
for i in a:
print i
ok you have full scan so the complexity is O(n)
and so forth
big_O is a Python module to estimate the time complexity of Python code from its execution time. It can be used to analyze how functions scale with inputs of increasing size.
Let's use T(n) as the total time in function of the input size n , and t as the time complexity taken by a statement or group of statements. T(n) = t(statement1) + t(statement2) + ... + t(statementN); If each statement executes a basic operation, we can say it takes constant time O(1) .
Unfortunately, infeasible. See Halting Problem.
It's not possible in general. Here's one python program that can compute the complexity for some program: https://github.com/Mortal/complexity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With