Package networkx :: Package tests :: Module benchmark :: Class Benchmark
[hide private]
[frames] | no frames]

Class Benchmark

source code

object --+
         |
        Benchmark

Benchmark a method or simple bit of code using different Graph classes. If the test code is the same for each graph class, then you can set it during instantiation through the argument test_string. The argument test_string can also be a tuple of test code and setup code. The code is entered as a string valid for use with the timeit module.

Example: >>> b=Benchmark(['Graph','XGraph']) >>> b['Graph']=('G.add_nodes_from(nlist)','nlist=range(100)') >>> b.run()



Instance Methods [hide private]
 
__init__(self, graph_classes, title='', test_string=None, runs=3, reps=1000)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__setitem__(self, graph_class, (test_str, setup_str))
Set a simple bit of code and setup string for the test.
source code
 
run(self)
Run the benchmark for each class and print results.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, graph_classes, title='', test_string=None, runs=3, reps=1000)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

__setitem__(self, graph_class, (test_str, setup_str))
(Index assignment operator)

source code 
Set a simple bit of code and setup string for the test. Use this for cases where the code differs from one class to another.