Skip to content

Commit 7a3b7cc

Browse files
committed
feat: Add ptop script
fix #6
1 parent f97e53f commit 7a3b7cc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

generate_test_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
parser.add_argument(
1111
"-n", default=100, type=int, help="Number of lines to generate"
1212
)
13-
1413
parser.add_argument(
1514
"-t",
1615
default="0.5-5",
@@ -30,8 +29,8 @@
3029
if random.random() < false_probability:
3130
print("false")
3231
else:
33-
3432
print(
3533
"sleep " + str(round(random.uniform(lower_bound, upper_bound), 2))
3634
)
3735

36+

ptop.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ def parse(input_line: str) -> dict:
3838
return parsed
3939

4040

41+
4142
def progress(lines, total_jobs):
4243
return (len(lines) / total_jobs) * 100 if total_jobs else 0
4344

4445

46+
4547
def ascii_progress_bar(percentage, bar_length=50):
4648
filled_length = int(bar_length * percentage // 100)
4749
bar = "█" * filled_length + "-" * (bar_length - filled_length)
@@ -60,6 +62,7 @@ def ascii_progress_bar(percentage, bar_length=50):
6062
lines.extend(new_lines)
6163

6264
clear_console()
65+
6366
print(ascii_progress_bar(progress(lines, tj)))
6467
print(
6568
"--------------------------------------------------------------"
@@ -112,6 +115,7 @@ def ascii_progress_bar(percentage, bar_length=50):
112115
f"{host:12} {throughput:.2f} {stats['total']:5} {stats['successful']:5} {stats['failed']:5}"
113116
)
114117

118+
115119
print(
116120
"--------------------------------------------------------------"
117121
)

0 commit comments

Comments
 (0)