예제 #1
0
import cProfile
from graph_goody import random_graph, spanning_tree
import pstats

# Put script here to generate data for Problem #2
# In case you fail, the data appears in sample8.pdf in the helper folder
correct_size_1 = random_graph(50000, lambda n: n * 10)
cProfile.run('spanning_tree(correct_size_1)', 'correct_size_1')
p = pstats.Stats('correct_size_1')
p.sort_stats('calls').print_stats()
correct_size_2 = random_graph(100000, lambda n: n * 10)
cProfile.run('spanning_tree(correct_size_2)', 'correct_size_2')
p = pstats.Stats('correct_size_2')
p.sort_stats('time').print_stats()
예제 #2
0
import cProfile
from graph_goody import random_graph, spanning_tree
import pstats

# Put script below to generate data for Problem #2
# In case you fail, the data appears in sample8.pdf in the helper folder

g1, g2 = random_graph(50000, lambda x: 50000 * 10), random_graph(
    100000, lambda x: 100000 * 10)
cProfile.run("spanning_tree(g1)", "Profile50K")
pstats.Stats('Profile50K').sort_stats('ncalls').print_stats()
cProfile.run("spanning_tree(g2)", "Profile100K")
pstats.Stats('Profile100K').sort_stats('tottime').print_stats()
예제 #3
0
import cProfile
from graph_goody import random_graph, spanning_tree
import pstats

# Put script below to generate data for Problem #2
# In case you fail, the data appears in sample8.pdf in the helper folder
if __name__ == '__main__':
    graph = random_graph(15000, lambda n: 10 * n)
    cProfile.run('spanning_tree(graph)', 'results.txt')
    #results = open('results.txt', 'b')
    stats = pstats.Stats('results.txt')
    stats.strip_dirs().sort_stats('ncalls').print_stats(10)
    stats.strip_dirs().sort_stats('tottime').print_stats(10)
예제 #4
0
def create_random(n, callable):
    return random_graph(n, callable)
예제 #5
0
import cProfile
from graph_goody import random_graph, spanning_tree
import pstats

# Put script below to generate data for Problem #2
# In case you fail, the data appears in sample8.pdf in the helper folder

graph1 = random_graph(5000, lambda n: 10 * n)
graph2 = random_graph(10000, lambda n: 10 * n)

cProfile.run('spanning_tree(graph1)', 'profile5K')
p1 = pstats.Stats('profile5K')
p1.strip_dirs().sort_stats('calls').print_stats()

cProfile.run('spanning_tree(graph2)', 'profile10K')
p2 = pstats.Stats('profile10K')
p2.strip_dirs().sort_stats('time').print_stats()
예제 #6
0
from performance import Performance
from goody import irange
from graph_goody import random_graph,spanning_tree
from graph import Graph

# Put script below to generate data for Problem #1
# In case you fail, the data appears in sample8.pdf in the helper folder
global nodes
global graph
if __name__ == '__main__':
    nodes = 1000
    while nodes <= 128000:
        graph = random_graph(nodes,lambda n : 10*n)
        perf = Performance(lambda: spanning_tree(graph),setup=lambda:None,times_to_measure=5,title='Spanning Tree Timings for '+str(nodes)+' nodes')
        perf.evaluate()
        perf.analyze()
        nodes *= 2
예제 #7
0
from performance import Performance
from goody import irange
from graph_goody import random_graph,spanning_tree

# Put script below to generate data for Problem #1
# In case you fail, the data appears in sample8.pdf in the helper folder
for i in range(8):
    size=(2**i)*1000
    g=random_graph(size,lambda x:x*10)
    p=Performance(lambda :spanning_tree(g),lambda :None,5,'\n\nSpanning Tree of size ' + str(size))
    p.evaluate()
    p.analyze()
예제 #8
0
 def create_random():
     return random_graph(nodes, multby10)
예제 #9
0
def create_random(n):
    global rand_graph
    rand_graph = random_graph(n, lambda n: 10*n)
예제 #10
0
from performance import Performance
from goody import irange
from graph_goody import random_graph, spanning_tree

# Put script below to generate data for Problem #1
# In case you fail, the data appears in sample8.pdf in the helper folder


def multby10(x: int) -> int:
    return x * 10


random_graph(8, multby10)
print(random_graph(8, multby10))
for x in range(8):
    nodes = 1000 * (2**x)
    print(nodes)

    def create_random():
        return random_graph(nodes, multby10)

    def spamming_tree():
        return spanning_tree(create_random())

    p = Performance(spamming_tree, create_random, 5,
                    'spanning tree of size ' + str(nodes))
    p.evaluate()
    p.analyze()
print("Done")
예제 #11
0
def creat_random(n):
    global correct_size
    correct_size = random_graph(n, lambda n: n * 10)
예제 #12
0
import cProfile
from graph_goody import random_graph, spanning_tree
import pstats

# Put script below to generate data for Problem #2
# In case you fail, the data appears in sample8.pdf in the helper folder
def multby10(x:int) -> int:
    return x*10
r1 = random_graph( 5000, multby10)
r2 = random_graph(10000, multby10)
cProfile.run('spanning_tree(r1)', 'profile')
p = pstats.Stats('profile')
#p.str_dirs().sort_stats(-1).print_stats()
p.sort_stats('calls').print_stats()
cProfile.run('spanning_tree(r2)', 'profile')
p = pstats.Stats('profile')
p.sort_stats('tottime').print_stats()
예제 #13
0
def create_random(size: int) -> 'Graph':
    return random_graph(size, lambda n: 10 * n)
예제 #14
0
def create_random(i):
    global graph
    graph = random_graph(i, lambda n : 10*n)