MCPcopy Create free account
hub / github.com/CyberPoint/libpgm / timer

Function timer

runtime-tests/timer.py:28–69  ·  view source on GitHub ↗
(inputfile, trials, datalength)

Source from the content-addressed store, hash-verified

26
27
28def timer(inputfile, trials, datalength):
29
30 # load nodedata and graphskeleton
31 nd = NodeData()
32 skel = GraphSkeleton()
33 #print "bp1"
34 nd.load(inputfile)
35 #print "bp2"
36 skel.load(inputfile)
37 #print "bp3"
38
39# msg = "%d, %d" % (asizeof(nd), asizeof(skel))
40 # print >>op, msg
41
42 # topologically order graphskeleton
43 skel.toporder()
44
45 # load bayesian network
46 bn = DiscreteBayesianNetwork(skel, nd)
47
48 # instantiate pgm learner
49 l = PGMLearner()
50
51 # free unused memory
52 del nd
53
54 #sum1 = summary.summarize(muppy.get_objects())
55 #summary.print_(sum1)
56
57 # TIME
58 totaltime = 0
59 for _ in range(trials):
60 data = bn.randomsample(datalength)
61 start = time.clock()
62 ret = l.discrete_mle_estimateparams(skel, data)
63 elapsed = time.clock() - start
64 totaltime += elapsed
65 totaltime /= trials
66
67
68 print json.dumps(ret.Vdata, indent=1)
69 return totaltime
70#timer("/home/ccabot/Documents/bayesian networks project/bayesian/v3_bayesian/PGMlibrary/unittestdict.txt", 10)
71

Callers 1

processor.pyFile · 0.90

Calls 9

loadMethod · 0.95
loadMethod · 0.95
toporderMethod · 0.95
randomsampleMethod · 0.95
NodeDataClass · 0.90
GraphSkeletonClass · 0.90
PGMLearnerClass · 0.90

Tested by

no test coverage detected