Skip to content

Commit cf6dfe6

Browse files
committed
Fixed instrumentation (reported in README.md)
1 parent d4de0f6 commit cf6dfe6

File tree

8 files changed

+30
-5
lines changed

8 files changed

+30
-5
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ In order to not put in 8 large images, I will insert the final screenshot, with
4343

4444
[Link the commit](https://github.com/CatalinAnt/algorithms-SEP-95/pull/2/commits/22ee6fa1df4785596c603af61a725c558973eb0b)
4545

46-
Screenshot of branch measurement (66%):<br>
47-
![image](image-7.png)
46+
Screenshot of branch measurement:<br>
47+
![alt text](image-7.png)
4848

4949
##### Function 2: insertion_sort
5050

5151
[Link to commit](https://github.com/CatalinAnt/algorithms-SEP-95/pull/2/commits/5dae7f28036f89b7f6ff673639a922dd714aff3e)
5252

53-
Screenshot of branch measurement (0%, was untested):<br>
54-
![alt text](image-8.png)
53+
Screenshot of branch measurement:<br>
54+
![alt text](image-11.png)
5555

5656
#### Catalin Antonescu
5757

@@ -139,6 +139,7 @@ Old coverage:<br>
139139

140140
Diff (LHS = new code, RHS = old code):<br>
141141
![LHS: new code, RHS: old code](image.png)
142+
![alt text](image-9.png)
142143

143144
New coverage:<br>
144145
![new coverage result (100%)](image-1.png)
@@ -157,6 +158,8 @@ Diff (LHS: new code, RHS: old code):<br>
157158
![LHS: new code, RHS: old code](image-5.png)<br>
158159
(Changes in imports)<br>
159160
![LHS: new code, RHS: old code](image-6.png)
161+
(Instrumentation)<br>
162+
![alt text](image-8.png)
160163

161164
Old coverage:<br>
162165
![Old coverage result (4%)](image-3.png)

algorithms/sort/insertion_sort.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,18 @@ def insertion_sort(arr, simulation=False):
3636
return arr
3737

3838
def print_coverage():
39+
covered = 0
3940
print("branch coverage for `insertion_sort`:")
4041
for branch, hit in branch_coverage.items():
4142
print(f"{branch} was {'hit' if hit else 'not hit'}")
43+
if hit: covered += 1;
44+
print(f"Branch coverage: {covered / len(branch_coverage) * 100}")
4245

46+
insertion_sort([])
47+
insertion_sort([1])
48+
insertion_sort([69, 420])
49+
insertion_sort([420, 69])
50+
insertion_sort([0, 1, 2, 3, 4, 3, 2, 1, 0])
51+
insertion_sort([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], True)
52+
insertion_sort([0, 1, 2, 3, 4, 3, 2, 1, 0], True)
53+
print_coverage()

algorithms/unix/path/simplify_path.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ def simplify_path_v2(path):
3939
return "/" + "/".join(stack)
4040

4141
def print_coverage():
42+
covered = 0
4243
print("branch coverage for `simplify_path_v2`:")
4344
for branch, hit in branch_coverage.items():
44-
print(f"{branch} was {'hit' if hit else 'not hit'}")
45+
print(f"{branch} was {'hit' if hit else 'not hit'}")
46+
if hit: covered += 1;
47+
print(f"Branch coverage: {covered / len(branch_coverage) * 100}")
48+
49+
50+
# simplify_path_v2(".")
51+
# simplify_path_v2("/../")
52+
# simplify_path_v2("/home//foo/")
53+
# simplify_path_v2("")
54+
# simplify_path_v2("/home/../")
55+
print_coverage()

image-10.png

15.1 KB
Loading

image-11.png

3.3 KB
Loading

image-7.png

-16.3 KB
Loading

image-8.png

16.3 KB
Loading

image-9.png

24.4 KB
Loading

0 commit comments

Comments
 (0)