forked from dennisklein/exercise_gnu_parallel_top
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06b3407
commit 513c83b
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |