88import matplotlib .pyplot as plt
99
1010
11- TIMEIT_TIMES = 100 # Increase number for smoother lines
12- LIST_SIZE = 1000
13- POSITION_INCREMENT = 10
11+ TIMEIT_TIMES = 1000000 # Increase number for smoother lines
12+ LIST_SIZE = 500
13+ POSITION_INCREMENT = 1000
1414
1515
1616def build_list (size , fill , value , at_position ):
@@ -69,9 +69,11 @@ def find_match_gen(iterable):
6969plot = ax .plot (positions , generator_times , label = "generator" )
7070
7171plt .xlim ([0 , LIST_SIZE ])
72- plt .xlabel ("Position of element to be found" )
7372plt .ylim ([0 , max (max (looping_times ), max (generator_times ))])
74- plt .ylabel (f"Time to complete { TIMEIT_TIMES :,} times" )
73+
74+ plt .xlabel ("Index of element to be found" )
75+ plt .ylabel (f"Time in seconds to find element { TIMEIT_TIMES :,} times" )
76+ plt .title ("Raw Time to Find First Match" )
7577plt .legend ()
7678
7779plt .show ()
@@ -89,9 +91,11 @@ def find_match_gen(iterable):
8991plot = ax .plot (positions , generator_ratio , label = "generator" )
9092
9193plt .xlim ([0 , LIST_SIZE ])
92- plt .xlabel ("Position of element to be found" )
9394plt .ylim ([0 , max (max (looping_ratio ), max (generator_ratio ))])
94- plt .ylabel (f"Time to complete { TIMEIT_TIMES :,} times" )
95+
96+ plt .xlabel ("Index of element to be found" )
97+ plt .ylabel ("Speed to find element, relative to loop" )
98+ plt .title ("Relative Speed to Find First Match" )
9599plt .legend ()
96100
97101plt .show ()
0 commit comments