Skip to content

Commit c392ae6

Browse files
committed
DR Updates
1 parent fa659f9 commit c392ae6

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

python-first/chart.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import 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

1616
def build_list(size, fill, value, at_position):
@@ -69,9 +69,11 @@ def find_match_gen(iterable):
6969
plot = ax.plot(positions, generator_times, label="generator")
7070

7171
plt.xlim([0, LIST_SIZE])
72-
plt.xlabel("Position of element to be found")
7372
plt.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")
7577
plt.legend()
7678

7779
plt.show()
@@ -89,9 +91,11 @@ def find_match_gen(iterable):
8991
plot = ax.plot(positions, generator_ratio, label="generator")
9092

9193
plt.xlim([0, LIST_SIZE])
92-
plt.xlabel("Position of element to be found")
9394
plt.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")
9599
plt.legend()
96100

97101
plt.show()

python-first/chart_gen_loop_in.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ def find_match_in(list_to_search, item_to_find):
8080
plot = ax.plot(positions, in_times, label="in")
8181

8282
plt.xlim([0, LIST_SIZE])
83-
plt.xlabel("Position of element to be found")
8483
plt.ylim([0, max(max(looping_times), max(generator_times), max(in_times))])
85-
plt.ylabel(f"Time to complete {TIMEIT_TIMES:,} times")
84+
85+
plt.xlabel("Index of element to be found")
86+
plt.ylabel(f"Time in seconds to find element {TIMEIT_TIMES:,} times")
87+
plt.title("Raw Time to Find First Match")
8688
plt.legend()
8789

8890
plt.show()
@@ -102,9 +104,10 @@ def find_match_in(list_to_search, item_to_find):
102104
plot = ax.plot(positions, in_ratio, label="in")
103105

104106
plt.xlim([0, LIST_SIZE])
105-
plt.xlabel("Position of element to be found")
106107
plt.ylim([0, max(max(looping_ratio), max(generator_ratio), max(in_ratio))])
107-
plt.ylabel(f"Time to complete {TIMEIT_TIMES:,} times")
108+
plt.xlabel("Index of element to be found")
109+
plt.ylabel("Speed to find element, relative to loop")
110+
plt.title("Relative Speed to Find First Match")
108111
plt.legend()
109112

110113
plt.show()

0 commit comments

Comments
 (0)