Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import timeit
- class app:
- def __init__(self):
- self.txt = "Hello"
- def ec(self):
- x = self.txt.casefold()
- def myImplementation(self):
- tekst = ''
- for i in range(len(self.txt)):
- c = ord(self.txt[i])
- if c > 64 and c < 90:
- c = c + 32
- tekst += chr(c)
- def run(self):
- self.time = timeit.Timer("d.ec()","from __main__ import app; d = app()")
- firstTime = self.time.timeit(number=10)
- print(firstTime)
- self.time = timeit.Timer("d.myImplementation()","from __main__ import app; d = app()")
- secondTime = self.time.timeit(number=10)
- print(secondTime)
- finalTime = secondTime / firstTime
- print("Final Time " + str(finalTime))
- if __name__ == "__main__":
- a = app()
- a.run()
- a.myImplementation()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement