Skip to content

Commit

Permalink
add numeric and real data to performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmicu committed Sep 10, 2023
1 parent 074b992 commit 431851f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
54 changes: 40 additions & 14 deletions test/generate_random_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
},
"foo": {
"allow_empty": True,
"datatype": "integer",
"datatype": "real",
"structure": {
"type": "foreign",
"ftable": "table4",
Expand Down Expand Up @@ -131,7 +131,7 @@
},
"numeric_foreign_column": {
"allow_empty": False,
"datatype": "integer",
"datatype": "real",
"structure": {
"type": "primary",
},
Expand All @@ -153,7 +153,7 @@
"table6": {
"child": {
"allow_empty": False,
"datatype": "integer",
"datatype": "real",
"structure": {
"type": "foreign",
"ftable": "table4",
Expand All @@ -162,15 +162,15 @@
},
"parent": {
"allow_empty": True,
"datatype": "integer",
"datatype": "real",
"structure": {
"type": "tree",
"tcolumn": "child",
},
},
"xyzzy": {
"allow_empty": True,
"datatype": "integer",
"datatype": "real",
"structure": {
"type": "under",
"ttable": "table6",
Expand All @@ -184,7 +184,7 @@
},
"bar": {
"allow_empty": True,
"datatype": "integer",
"datatype": "numeric",
},
},
}
Expand Down Expand Up @@ -261,11 +261,18 @@ def get_constrained_cell_value(table, column, row_num, prev_inserts):
+ " "
+ "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
)
elif CONFIG[table][column]["datatype"] == "integer":
elif CONFIG[table][column]["datatype"] in ["integer", "real", "numeric"]:
# No leading 0s:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
)
if CONFIG[table][column]["datatype"] != "integer":
cell = (
cell
+ "."
+ "".join(random.choices("0123456789", k=1))
+ "".join(random.choices(string.digits, k=3))
)
else:
print(
f"Warning: Unknown datatype: {CONFIG[table][column]['datatype']}. "
Expand Down Expand Up @@ -349,14 +356,33 @@ def main():
+ " "
+ "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
)
else:
if CONFIG[table][column]["datatype"] == "integer":
cell = "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
else:
# No leading 0s:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
elif CONFIG[table][column]["datatype"] == "text":
# No leading 0s:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
)
# Randomly add some decimal places:
if random.choice([True, False]):
cell = (
cell
+ "."
+ "".join(random.choices("0123456789", k=1))
+ "".join(random.choices(string.digits, k=3))
)
elif CONFIG[table][column]["datatype"] != "integer":
cell = "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
elif random.choice([True, False]):
cell = "".join(random.choices(string.ascii_lowercase, k=TOKEN_LENGTH))
else:
cell = "".join(random.choices("123456789", k=1)) + "".join(
random.choices(string.digits, k=TOKEN_LENGTH - 1)
)
cell = (
cell
+ "."
+ "".join(random.choices("0123456789", k=1))
+ "".join(random.choices(string.digits, k=3))
)

row[column] = cell
if not prev_inserts.get(table):
Expand Down
4 changes: 3 additions & 1 deletion test/perf_test_data/datatype.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ label trimmed_line match(/\S([^\n]*\S)*/)
line text exclude(/\n/) a line of text input
natural_number integer match(/\d+/) a natural number, including zero INTEGER INTEGER
nonspace trimmed_line exclude(/\s/) text without whitespace
numeric nonspace match(/-?\d+(\.\d+)?/) a positive or negative number NUMERIC NUMERIC
path line exclude(/\n/) a path to a file
prefix word exclude(/\W/) a prefix for a CURIE
real nonspace match(/-?\d+(\.\d+)?/) a positive or negative real number REAL REAL
suffix word exclude(/\W/) a suffix for a CURIE
table_name word exclude(/\W/) a table name
table_type word lowercase in('table', 'column', 'datatype') a table type
text any text TEXT TEXT xsd:string textarea
text any text TEXT VARCHAR(100) xsd:string textarea
trimmed_line line match(/\S([^\n]*\S)*/) a line of text that does not begin or end with whitespace
trimmed_text text exclude(/^\s+|\s+$/) text that does not begin or end with whitespace
word nonspace exclude(/\W/) a single word: letters, numbers, underscore

0 comments on commit 431851f

Please sign in to comment.