from dendropy import TaxonNamespace, Tree from dendropy.calculate import treecompare import time num_iter = 100 with open("sim_trees", "r") as f: trees = [i.split("\t") for i in f.readlines()] with open("dendropy-postord-times.csv", "w") as f: for (t1_str, t2_str) in trees: start_time = time.time() for i in range(num_iter): tns = TaxonNamespace() tree1 = Tree.get( data=t1_str, schema="newick", taxon_namespace=tns) x = list(tree1.postorder_node_iter()) f.write(f"{len(tree1)},{((time.time()-start_time)*1000)/num_iter}\n")