Various optimizations, Readme update, Bench script for imports
This commit is contained in:
@ -20,17 +20,24 @@ function parse_edges(input::AbstractString)
|
||||
return output
|
||||
end
|
||||
|
||||
function importTxt(filename::String)
|
||||
function import_txt(filename::String, verbose::Bool = isinteractive())
|
||||
file = open(filename, "r")
|
||||
|
||||
println("Opened file")
|
||||
if (verbose) println("Opened file") end
|
||||
nodes_string = readline(file)
|
||||
nodes = parse_nodes(nodes_string)
|
||||
|
||||
close(file)
|
||||
println("Read file")
|
||||
if (verbose) println("Read file") end
|
||||
|
||||
graph = DAG()
|
||||
|
||||
# estimate total number of nodes
|
||||
# try to slightly overestimate so no resizing is necessary
|
||||
# data nodes are not included in length(nodes) and there are a few more than compute nodes
|
||||
estimate_no_nodes = round(Int, length(nodes) * 4)
|
||||
if (verbose) println("Estimating ", estimate_no_nodes, " Nodes") end
|
||||
sizehint!(graph.nodes, estimate_no_nodes)
|
||||
|
||||
sum_node = insert_node(graph, make_node(ComputeTaskSum()))
|
||||
global_data_out = insert_node(graph, make_node(DataTask(10)))
|
||||
@ -39,14 +46,14 @@ function importTxt(filename::String)
|
||||
# remember the data out nodes for connection
|
||||
dataOutNodes = Dict()
|
||||
|
||||
println("Building graph")
|
||||
if (verbose) println("Building graph") end
|
||||
noNodes = 0
|
||||
nodesToRead = length(nodes)
|
||||
while !isempty(nodes)
|
||||
node = popfirst!(nodes)
|
||||
noNodes += 1
|
||||
if (noNodes % 100 == 0)
|
||||
@printf "\rReading Nodes... %.2f%%" (100. * noNodes / nodesToRead)
|
||||
if (verbose) @printf "\rReading Nodes... %.2f%%" (100. * noNodes / nodesToRead) end
|
||||
end
|
||||
if occursin(regex_a, node)
|
||||
# add nodes and edges for the state reading to u(P(Particle))
|
||||
@ -127,7 +134,10 @@ function importTxt(filename::String)
|
||||
|
||||
insert_edge(graph, make_edge(data_out, sum_node))
|
||||
elseif occursin(regex_plus, node)
|
||||
println("\rReading Nodes Complete ")
|
||||
if (verbose)
|
||||
println("\rReading Nodes Complete ")
|
||||
println("Added ", length(graph.nodes), " nodes")
|
||||
end
|
||||
else
|
||||
error("Unknown node '", node, "' while reading from file ", filename)
|
||||
end
|
||||
|
Reference in New Issue
Block a user