mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Stopwatch can now be concat to a string without
any extra function calls
This commit is contained in:
@@ -155,3 +155,12 @@ class Stopwatch:
|
|||||||
|
|
||||||
#Return the string
|
#Return the string
|
||||||
return timeString
|
return timeString
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.getString()
|
||||||
|
|
||||||
|
def __add__(self, other):
|
||||||
|
return self.getString() + other
|
||||||
|
|
||||||
|
def __radd__(self, other):
|
||||||
|
return other + self.getString()
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ else:
|
|||||||
|
|
||||||
#Print the results
|
#Print the results
|
||||||
print("\nHere is a printing of the different times, starting with the string:")
|
print("\nHere is a printing of the different times, starting with the string:")
|
||||||
|
print("It took " + timer + " to run this algorithm")
|
||||||
print("It took " + timer.getString() + " to run this algorithm")
|
print("It took " + timer.getString() + " to run this algorithm")
|
||||||
print("It took " + str(timer.getNanoseconds()) + " nanoseconds to run this algorithm")
|
print("It took " + str(timer.getNanoseconds()) + " nanoseconds to run this algorithm")
|
||||||
print("It took " + str(timer.getMicroseconds()) + " microseconds to run this algorithm")
|
print("It took " + str(timer.getMicroseconds()) + " microseconds to run this algorithm")
|
||||||
|
|||||||
Reference in New Issue
Block a user