Neo4j+py2neo performance Test (CMDB II)
Performance test: local notebook, CPU: i5, memory: 8G, win7_x64, python 2.7, neo4j comunity 2.0.
It takes 1 minute and 51 seconds to create 60000 CI, with an average of 540 CI per second. Each CI contains 3-7 attributes.
In [11]: py2neo_initialzation.create_ci (10000)
10000X6CIs
Tue Dec 24 17:04:43 2013
Tue Dec 24 17:06:34 2013
It took 4 minutes and 27 seconds to create 50000 associations, with an average of 1 second creating 50000 relationship.
In [12]: py2neo_initialzation.create_relationship (10000)
Tue Dec 24 17:07:23 2013
Tue Dec 24 17:11:50 2013
Test the code:
From py2neo import node Relfrom py2neo import neo4jimport timeimport datetimeg=neo4j.GraphDatabaseService ('http://localhost:7474/db/data')import cmdb.py2neo_function as neofunction# data initialize#storagedef create_ci (total_ci): print'% dX6CIs'% total_ci print time.ctime () for i in range (total_ci): storage_name='storage_%d'% I small_server_name='aix_%d'% I lpar_name='lpar _% d'% I db_name='db_%d'% I was_name='was_%d'% I app_name='app_%d'% I g.create (node (ci_class='storage') City='Shanghai',district='PuDong',name=storage_name,rack=1,capacity=300), node (ci_class='small_server',city='Shanghai',district='PuDong',name=small_server_name,cpu_count=16,mem_GB=64), node (ci_class='lpar',city='Shanghai',district='PuDong',name=lpar_name,cpu_count=1,mem_GB=2), node (ci_class='db_instance',name=db_name,type='db2') Version='9.1'), node (ci_class='was_node',name=was_name,version='6.1'), node (ci_class='application',name=app_name)) print time.ctime () def create_relationship (total_ci): # get the nodes # get all storeage nodes print 'get all storage nodes Count number about% d'% total_ci print datetime.datetime.now () storage_list=neofunction.SearchNodes print datetime.datetime.now () # get all small_server nodes small_server_list=neofunction.SearchNodes ((small_server_list [0], 'depend_on') Storage_ list [0]) # get all lpar nodes lpar_list=neofunction.SearchNodes # get all was nodes was_list=neofunction.SearchNodes (gGramingly cipher classclassrecy wasteful node') # get all db_instance nodes dbi_list=neofunction.SearchNodes (gparamentcience classrooms classrooms dactyinstance') # get all app nodes app_list=neofunction.SearchNodes (gheroine baby classbooks 'application') print time.ctime () for i in range (total_ci): g.create ((lpar_ list [I],' depend_on',small_server_ list [I]) g.create ((dbi_ list [I], 'running_on',lpar_ list [I])) g.create ((was_list [I],' running_on') Lpar_ list [I]) g.create ((app_ list [I], 'depend_on',dbi_ list [I]) g.create ((app_ list [I],' depend_on',was_ list [I])) print time.ctime ()