Misc Cleanup Update
This commit is contained in:
@@ -28,7 +28,7 @@ def generateNumber(numberLenght, startingNumber):
|
|||||||
return number
|
return number
|
||||||
|
|
||||||
|
|
||||||
# Function for writing data into a file
|
# Function for writing data into a file
|
||||||
# content = string, nameChunkStart and namePartStart are for better naming
|
# content = string, nameChunkStart and namePartStart are for better naming
|
||||||
# /testdata/ folder has to be created at this point
|
# /testdata/ folder has to be created at this point
|
||||||
def writeFile(content, nameChunkStart, namePartStart):
|
def writeFile(content, nameChunkStart, namePartStart):
|
||||||
@@ -56,7 +56,7 @@ def numGen(entries, cluster, int_lenght, suffle_value):
|
|||||||
generateNumber(
|
generateNumber(
|
||||||
int_lenght - 1,
|
int_lenght - 1,
|
||||||
clusterArray[cluster_decider]
|
clusterArray[cluster_decider]
|
||||||
))
|
))
|
||||||
|
|
||||||
if suffle_value:
|
if suffle_value:
|
||||||
shuffle(dataArray)
|
shuffle(dataArray)
|
||||||
|
|||||||
@@ -11,68 +11,77 @@ from datetime import date
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
# randomI function which creates each file
|
# randomI function which creates each file
|
||||||
|
|
||||||
|
|
||||||
def randomI(units, rows, rowLength, partstart):
|
def randomI(units, rows, rowLength, partstart):
|
||||||
for setcounter in range(0, units):
|
for setcounter in range(0, units):
|
||||||
writeFile(generateFile(rows, rowLength), setcounter, partstart)
|
writeFile(generateFile(rows, rowLength), setcounter, partstart)
|
||||||
|
|
||||||
# Function for generating the content of one single file
|
# Function for generating the content of one single file
|
||||||
|
|
||||||
|
|
||||||
def generateFile(rows, rowLength):
|
def generateFile(rows, rowLength):
|
||||||
content = []
|
content = []
|
||||||
for y in range(0, rows):
|
for y in range(0, rows):
|
||||||
content.append(generateRow(rowLength))
|
content.append(generateRow(rowLength))
|
||||||
return content
|
return content
|
||||||
|
|
||||||
# Function for generating the content of one single row randomly
|
# Function for generating the content of one single row randomly
|
||||||
|
|
||||||
|
|
||||||
def generateRow(rowLength):
|
def generateRow(rowLength):
|
||||||
row = ""
|
row = ""
|
||||||
for z in range(0, rowLength):
|
for z in range(0, rowLength):
|
||||||
row = row + str(randint(0, 9))
|
row = row + str(randint(0, 9))
|
||||||
return row
|
return row
|
||||||
|
|
||||||
# Function for writing data into a file
|
# Function for writing data into a file
|
||||||
|
|
||||||
|
|
||||||
def writeFile(content, setcounter, partstart):
|
def writeFile(content, setcounter, partstart):
|
||||||
filenumber = int(setcounter) + int(partstart)
|
filenumber = int(setcounter) + int(partstart)
|
||||||
file = open("testdata/file" + str(filenumber) + ".txt", "w")
|
file = open("testdata/file" + str(filenumber) + ".txt", "w")
|
||||||
for w in range(0, len(content)):
|
for w in range(0, len(content)):
|
||||||
file.write(content[w] + "\n")
|
file.write(content[w] + "\n")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Getting the user input
|
# Getting the user input
|
||||||
print("Hello World")
|
print("Hello World")
|
||||||
units = int(input("How many units would you like to generate? "))
|
units = int(input("How many units would you like to generate? "))
|
||||||
rows = int(input("How many rows should each unit have? "))
|
rows = int(input("How many rows should each unit have? "))
|
||||||
rowLength = int(input("How long should each row be? "))
|
rowLength = int(input("How long should each row be? "))
|
||||||
cores = int(input("How many cores do you want to use? "))
|
cores = int(input("How many cores do you want to use? "))
|
||||||
|
|
||||||
# Splitting up the units
|
# Splitting up the units
|
||||||
count = int(0)
|
count = int(0)
|
||||||
partsize = units / cores
|
partsize = units / cores
|
||||||
|
|
||||||
# For benchmarking starting the timer now
|
# For benchmarking starting the timer now
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Initialize and prepare cores for process
|
# Initialize and prepare cores for process
|
||||||
while count < cores:
|
while count < cores:
|
||||||
partstart = partsize * count
|
partstart = partsize * count
|
||||||
globals()["p" + str(count)] = multiprocessing.Process(target=randomI, args=(int(partsize), rows, rowLength, partstart))
|
globals()["p" + str(count)] = multiprocessing.Process(target=randomI, args=(int(partsize), rows, rowLength, partstart))
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
# Starting each core
|
# Starting each core
|
||||||
count = int(0)
|
count = int(0)
|
||||||
while count < cores:
|
while count < cores:
|
||||||
globals()["p" + str(count)].start()
|
globals()["p" + str(count)].start()
|
||||||
print("Core " + str(count) + " started.")
|
print("Core " + str(count) + " started.")
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
print("Working...")
|
print("Working...")
|
||||||
|
|
||||||
# Joining each core for the process
|
# Joining each core for the process
|
||||||
count = int(0)
|
count = int(0)
|
||||||
while count < cores:
|
while count < cores:
|
||||||
globals()["p" + str(count)].join()
|
globals()["p" + str(count)].join()
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
# Finishing up the process
|
# Finishing up the process
|
||||||
sec = time.time() - start_time
|
sec = time.time() - start_time
|
||||||
print("Data is generated. Have fun!")
|
print("Data is generated. Have fun!")
|
||||||
print("randomI took " + str(sec) + " seconds for execution.")
|
print("randomI took " + str(sec) + " seconds for execution.")
|
||||||
|
|||||||
39
src/main.py
39
src/main.py
@@ -1,36 +1,35 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#title: main.py
|
# title: main.py
|
||||||
#description:
|
# description:
|
||||||
#author: Conrad Großer
|
# author: Conrad Großer
|
||||||
#license: https://github.com/tchemn/miner/blob/master/LICENSE
|
# license: https://github.com/tchemn/miner/blob/master/LICENSE
|
||||||
#date: 02.06.2018
|
# date: 02.06.2018
|
||||||
#version: 0.1
|
# version: 0.1
|
||||||
#usage: PENDING
|
# usage: PENDING
|
||||||
#notes:
|
# notes:
|
||||||
#dependencies:
|
# dependencies:
|
||||||
#known_issues:
|
# known_issues:
|
||||||
#python_version: 3.x
|
# python_version: 3.x
|
||||||
#==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# IMPORTS
|
# IMPORTS
|
||||||
|
|
||||||
# Importing the time for benchmarking purposes
|
# Importing the time for benchmarking purposes
|
||||||
import time
|
import time
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
# CODE (FUNCTIONS)
|
# CODE
|
||||||
|
|
||||||
|
|
||||||
# EXECUTION
|
# EXECUTION
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Print welcoming message
|
# Print welcoming message
|
||||||
print("Hello world")
|
print("Hello world")
|
||||||
|
|
||||||
# For benchmarking starting the timer now
|
# For benchmarking starting the timer now
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Get parameters, call functions, execute program (...)
|
# Get parameters, call functions, execute program (...)
|
||||||
|
|
||||||
# BENCHMARKING [END]
|
# BENCHMARKING [END]
|
||||||
sec = time.time() - start_time
|
sec = time.time() - start_time
|
||||||
print("The program took " + str(sec) + " seconds (" + str(sec/60) + " minutes) for execution.")
|
print("The program took " + str(sec) + " seconds (" + str(sec/60) + " minutes) for execution.")
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
# Main method of the importer
|
# Main method of the importer
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("IMPORTER MODULE")
|
print("IMPORTER MODULE")
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#title: template.py
|
# title: template.py
|
||||||
#description: Template for any programm
|
# description: Template for any programm
|
||||||
#author: Authors seperated by comma
|
# author: Authors seperated by comma
|
||||||
#license: License for the programm
|
# license: License for the programm
|
||||||
#date: Date of creation
|
# date: Date of creation
|
||||||
#version: Versionnumber
|
# version: Versionnumber
|
||||||
#usage: Description of how to use the programm quickly
|
# usage: Description of how to use the programm quickly
|
||||||
#notes: Notes for parameters, thanks (...)
|
# notes: Notes for parameters, thanks (...)
|
||||||
#dependencies: Preinstalled packages
|
# dependencies: Preinstalled packages
|
||||||
#known_issues: Known issues in this version
|
# known_issues: Known issues in this version
|
||||||
#python_version: Compatible (tested) python version
|
# python_version: Compatible (tested) python version
|
||||||
#==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
# IMPORTS
|
# IMPORTS
|
||||||
|
|
||||||
@@ -23,14 +23,14 @@ from datetime import date
|
|||||||
|
|
||||||
# EXECUTION
|
# EXECUTION
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Print welcoming message
|
# Print welcoming message
|
||||||
print("Hello world")
|
print("Hello world")
|
||||||
|
|
||||||
# For benchmarking starting the timer now
|
# For benchmarking starting the timer now
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Get parameters, call functions, execute program (...)
|
# Get parameters, call functions, execute program (...)
|
||||||
|
|
||||||
# BENCHMARKING [END]
|
# BENCHMARKING [END]
|
||||||
sec = time.time() - start_time
|
sec = time.time() - start_time
|
||||||
print("The program took " + str(sec) + " seconds (" + str(sec/60) + " minutes) for execution.")
|
print("The program took " + str(sec) + " seconds (" + str(sec/60) + " minutes) for execution.")
|
||||||
|
|||||||
Reference in New Issue
Block a user