Skip to content

Instantly share code, notes, and snippets.

@sancarn
Last active March 19, 2018 22:17
Show Gist options
  • Save sancarn/3d22cf8cd80ea1f6b38b6d957e772e10 to your computer and use it in GitHub Desktop.
Save sancarn/3d22cf8cd80ea1f6b38b6d957e772e10 to your computer and use it in GitHub Desktop.
Time taken: 23.347s (response = 535 model objects, ran immediately after opening Database)
t1 = Time.now
$dbListPaths=""
def walk(moc)
moc.each do |mo|
$dbListPaths += mo.path + "\n"
walk(mo.children)
end
end
root_objects = WSApplication.current_database.root_model_objects
walk(root_objects)
t2 = Time.now
puts "Time taken: #{t2-t1}"
puts $dbListPaths
Time taken: 2.772s (response = 535 model objects, ran immediately after opening Database)
t1 = Time.now
$dbListCounter=0
$dbListPaths=""
def walk(moc)
$dbListCounter+=1
moc.each do |mo|
$dbListPaths += mo.path + "\n"
Thread.new{walk(mo.children)}
end
$dbListCounter-=1
end
root_objects = WSApplication.current_database.root_model_objects
walk(root_objects)
sleep(0.1) until $dbListCounter==0
t2 = Time.now
puts "Time taken: #{t2-t1}"
puts $dbListPaths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment