Misc Cleanup Update

This commit is contained in:
2019-07-04 18:39:01 +02:00
parent 0269c384da
commit 841d47e9c1
7 changed files with 95 additions and 87 deletions

View File

@@ -56,7 +56,7 @@ def numGen(entries, cluster, int_lenght, suffle_value):
generateNumber(
int_lenght - 1,
clusterArray[cluster_decider]
))
))
if suffle_value:
shuffle(dataArray)

View File

@@ -11,68 +11,77 @@ from datetime import date
import multiprocessing
# randomI function which creates each file
def randomI(units, rows, rowLength, partstart):
for setcounter in range(0, units):
writeFile(generateFile(rows, rowLength), setcounter, partstart)
for setcounter in range(0, units):
writeFile(generateFile(rows, rowLength), setcounter, partstart)
# Function for generating the content of one single file
def generateFile(rows, rowLength):
content = []
for y in range(0, rows):
content.append(generateRow(rowLength))
return content
content = []
for y in range(0, rows):
content.append(generateRow(rowLength))
return content
# Function for generating the content of one single row randomly
def generateRow(rowLength):
row = ""
for z in range(0, rowLength):
row = row + str(randint(0, 9))
return row
row = ""
for z in range(0, rowLength):
row = row + str(randint(0, 9))
return row
# Function for writing data into a file
def writeFile(content, setcounter, partstart):
filenumber = int(setcounter) + int(partstart)
file = open("testdata/file" + str(filenumber) + ".txt", "w")
for w in range(0, len(content)):
file.write(content[w] + "\n")
filenumber = int(setcounter) + int(partstart)
file = open("testdata/file" + str(filenumber) + ".txt", "w")
for w in range(0, len(content)):
file.write(content[w] + "\n")
if __name__ == '__main__':
# Getting the user input
print("Hello World")
units = int(input("How many units would you like to generate? "))
rows = int(input("How many rows should each unit have? "))
rowLength = int(input("How long should each row be? "))
cores = int(input("How many cores do you want to use? "))
# Getting the user input
print("Hello World")
units = int(input("How many units would you like to generate? "))
rows = int(input("How many rows should each unit have? "))
rowLength = int(input("How long should each row be? "))
cores = int(input("How many cores do you want to use? "))
# Splitting up the units
count = int(0)
partsize = units / cores
# Splitting up the units
count = int(0)
partsize = units / cores
# For benchmarking starting the timer now
start_time = time.time()
# For benchmarking starting the timer now
start_time = time.time()
# Initialize and prepare cores for process
while count < cores:
partstart = partsize * count
globals()["p" + str(count)] = multiprocessing.Process(target=randomI, args=(int(partsize), rows, rowLength, partstart))
count = count + 1
# Initialize and prepare cores for process
while count < cores:
partstart = partsize * count
globals()["p" + str(count)] = multiprocessing.Process(target=randomI, args=(int(partsize), rows, rowLength, partstart))
count = count + 1
# Starting each core
count = int(0)
while count < cores:
globals()["p" + str(count)].start()
print("Core " + str(count) + " started.")
count = count + 1
# Starting each core
count = int(0)
while count < cores:
globals()["p" + str(count)].start()
print("Core " + str(count) + " started.")
count = count + 1
print("Working...")
print("Working...")
# Joining each core for the process
count = int(0)
while count < cores:
globals()["p" + str(count)].join()
count = count + 1
# Joining each core for the process
count = int(0)
while count < cores:
globals()["p" + str(count)].join()
count = count + 1
# Finishing up the process
sec = time.time() - start_time
print("Data is generated. Have fun!")
print("randomI took " + str(sec) + " seconds for execution.")
# Finishing up the process
sec = time.time() - start_time
print("Data is generated. Have fun!")
print("randomI took " + str(sec) + " seconds for execution.")

View File

@@ -1,35 +1,34 @@
#!/usr/bin/env python
#title: main.py
#description:
#author: Conrad Großer
#license: https://github.com/tchemn/miner/blob/master/LICENSE
#date: 02.06.2018
#version: 0.1
#usage: PENDING
#notes:
#dependencies:
#known_issues:
#python_version: 3.x
#==============================================================================
# title: main.py
# description:
# author: Conrad Großer
# license: https://github.com/tchemn/miner/blob/master/LICENSE
# date: 02.06.2018
# version: 0.1
# usage: PENDING
# notes:
# dependencies:
# known_issues:
# python_version: 3.x
# ==============================================================================
# IMPORTS
# Importing the time for benchmarking purposes
import time
from datetime import date
# CODE (FUNCTIONS)
# CODE
# EXECUTION
if __name__ == '__main__':
# Print welcoming message
print("Hello world")
# Print welcoming message
print("Hello world")
# For benchmarking starting the timer now
start_time = time.time()
# For benchmarking starting the timer now
start_time = time.time()
# Get parameters, call functions, execute program (...)
# Get parameters, call functions, execute program (...)
# BENCHMARKING [END]
sec = time.time() - start_time

View File

@@ -3,4 +3,4 @@
# Main method of the importer
if __name__ == '__main__':
print("IMPORTER MODULE")
print("IMPORTER MODULE")

View File

@@ -1,16 +1,16 @@
#!/usr/bin/env python
#title: template.py
#description: Template for any programm
#author: Authors seperated by comma
#license: License for the programm
#date: Date of creation
#version: Versionnumber
#usage: Description of how to use the programm quickly
#notes: Notes for parameters, thanks (...)
#dependencies: Preinstalled packages
#known_issues: Known issues in this version
#python_version: Compatible (tested) python version
#==============================================================================
# title: template.py
# description: Template for any programm
# author: Authors seperated by comma
# license: License for the programm
# date: Date of creation
# version: Versionnumber
# usage: Description of how to use the programm quickly
# notes: Notes for parameters, thanks (...)
# dependencies: Preinstalled packages
# known_issues: Known issues in this version
# python_version: Compatible (tested) python version
# ==============================================================================
# IMPORTS
@@ -23,13 +23,13 @@ from datetime import date
# EXECUTION
if __name__ == '__main__':
# Print welcoming message
print("Hello world")
# Print welcoming message
print("Hello world")
# For benchmarking starting the timer now
start_time = time.time()
# For benchmarking starting the timer now
start_time = time.time()
# Get parameters, call functions, execute program (...)
# Get parameters, call functions, execute program (...)
# BENCHMARKING [END]
sec = time.time() - start_time