Skip to content

Commit

Permalink
the test data genarator
Browse files Browse the repository at this point in the history
  • Loading branch information
Apfelholz authored and dennisklein committed Oct 29, 2024
1 parent 06b3407 commit 513c83b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions generate_test_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import random
import argparse

# Command Line Argument Parser
parser = argparse.ArgumentParser(
prog='generate_test_data',
description='Generates a .txt file that contains n lines of sleep() statements within the specified range'
)

parser.add_argument('-n', type=int, help='Number of lines to generate')
parser.add_argument('-t', help='Range for sleep times, formatted as lower-upper')

# Initialisieren der Grenzen und Argumente
args = parser.parse_args()

if args.t is None:
lower_bound = 0.2
upper_bound = 0.5
else:
lower_bound, upper_bound = map(float, args.t.split('-'))

lines = args.n if args.n is not None else 100

# Datei erstellen oder überschreiben
with open("test_sleep.txt", "w") as datei:
for i in range(lines):
datei.write("sleep " + str(round(random.uniform(lower_bound, upper_bound), 2)) + "\n")

0 comments on commit 513c83b

Please sign in to comment.