Skip to content

Instantly share code, notes, and snippets.

@huned
Created April 18, 2013 15:05
Show Gist options
  • Select an option

  • Save huned/5413447 to your computer and use it in GitHub Desktop.

Select an option

Save huned/5413447 to your computer and use it in GitHub Desktop.
## import sample BOM (use db/BOMs/2/*.csv for a big BOM)
$ time bin/rails runner "BomNode.import_csv 'db/BOMs/2/parts.csv'"
NOTICE: index "bom_nodes_index" does not exist, skipping
real 5m44.958s
user 5m13.760s
sys 0m2.562s
$ time bin/rails runner "BomEdge.import_csv 'db/BOMs/2/bom.csv'"
NOTICE: index "bom_edges_index" does not exist, skipping
real 3m42.675s
user 3m11.811s
sys 0m2.454s
## cleanse the data
$ time bin/rails runner 'BomEdge.where("parent = child").delete_all'
real 0m1.982s
user 0m1.413s
sys 0m0.356s
## post process the imported data
$ time bin/rails runner 'BomNode.mark_root_nodes!'
real 1m24.289s
user 0m1.485s
sys 0m0.363s
$ time bin/rails runner 'BomNode.mark_leaf_nodes!'
real 0m13.218s
user 0m1.397s
sys 0m0.339s
## flatten graph in-memory and persist flattened graph to db
$ time bin/rails runner 'BomFlattener.serialize_flattened_graph(BomFlattener.flatten_graph)'
NOTICE: index "flattened_bom_index" does not exist, skipping
real 5m4.015s
user 4m46.532s
sys 0m1.614s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment