Compare commits

...

2 commits

3 changed files with 389 additions and 2225 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,105 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 26,
"id": "f7776815",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"folder = \"/home/sfischer/Documents/projects/wk_LinProg/simulation/results/log_raw\"\n",
"txt_files = [f for f in os.listdir(folder) if f.endswith('.txt')]\n",
"\n",
"if len(txt_files) == 0:\n",
" raise FileNotFoundError(\"No .txt files found in the folder.\")\n",
"elif len(txt_files) > 1:\n",
" raise RuntimeError(f\"Multiple .txt files found: {txt_files}\")\n",
"\n",
" # Do something with 'content'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "63d802a8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" timestamp src_task dst_task compute_time from_time to_time\n",
"0 101981000 70 0 0 101981 101981\n",
"1 101981000 71 10 0 101981 101981\n",
"2 101981000 72 12 0 101981 101981\n",
"3 101981000 73 17 0 101981 101981\n",
"4 101981000 74 26 0 101981 101981\n",
".. ... ... ... ... ... ...\n",
"113 123135000 60 61 483 123135 123618\n",
"114 123188000 65 66 563 123188 123751\n",
"115 123618000 61 69 644 123618 124262\n",
"116 123751000 66 69 644 123751 124395\n",
"117 124403000 69 56 211 124403 124614\n",
"\n",
"[118 rows x 6 columns]\n"
]
}
],
"source": [
"\n",
"import pandas as pd\n",
"import re\n",
"data = []\n",
"file_path = os.path.join(folder, txt_files[0])\n",
"with open(file_path, 'r') as f:\n",
"\n",
" for line in f:\n",
" if \"compute time\" in line:\n",
" numbers = re.findall(r'\\d+', line)\n",
" # print(f\"Found numbers: {numbers}\")\n",
"\n",
" # Assigning numbers to variables based on their position\n",
" timestamp = int(numbers[0])\n",
" src_task = int(numbers[2])\n",
" dst_task = int(numbers[3])\n",
" compute_time = int(numbers[4])\n",
" from_time = int(numbers[5])\n",
" to_time = int(numbers[6])\n",
" print(line)\n",
" print(f\"timestamp: {timestamp}\")\n",
" print(f\"src_task: {src_task}\")\n",
" print(f\"dst_task: {dst_task}\")\n",
" print(f\"compute_time: {compute_time}\")\n",
" print(f\"from_time: {from_time}\")\n",
" print(f\"to_time: {to_time}\")\n",
" data.append([timestamp, src_task, dst_task, compute_time, from_time, to_time])\n",
"\n",
"df = pd.DataFrame(data, columns=[\"timestamp\", \"src_task\", \"dst_task\", \"compute_time\", \"from_time\", \"to_time\"])\n",
"print(df)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "env",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View file

@ -0,0 +1,30 @@
import csv
import sys
def main(filename):
min_start = None
max_finish = None
with open(filename, newline='') as csvfile:
reader = csv.reader(csvfile)
header = next(reader) # Skip header
for row in reader:
if len(row) < 3:
continue # Skip malformed rows
start = int(row[1].strip())
finish = int(row[2].strip())
if min_start is None or start < min_start:
min_start = start
if max_finish is None or finish > max_finish:
max_finish = finish
print(f"Min start time: {min_start}")
print(f"Max finish time: {max_finish}")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python getResults.py <csv_file>")
else:
main(sys.argv[1])