← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2783: 1. Performance test is added. Initial script.

 

------------------------------------------------------------
revno: 2783
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Wed 2011-03-16 17:09:44 +0100
message:
  1. Performance test is added. Initial script.
added:
  scripts/test/performance/
  scripts/test/performance/checkPerf.py
modified:
  core/main/main.py.in


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/main/main.py.in'
--- core/main/main.py.in	2011-02-21 14:45:36 +0000
+++ core/main/main.py.in	2011-03-16 16:09:44 +0000
@@ -35,6 +35,7 @@
 par.add_option('--test',help="Run regression test suite and exit; the exists status is 0 if all tests pass, 1 if a test fails and 2 for an unspecified exception.",dest="test",action='store_true')
 par.add_option('--debug',help='Run the debug build, if available.',dest='debug',action='store_true')
 par.add_option('--checks',help='Run a series of user-defined check tests as described in ${sourceRoot}/scripts/test/checks/README',dest='checks',action='store_true')
+par.add_option('--performance',help='Starts a test to measure the productivity',dest='performance',action='store_true')
 par.add_option('--no-gdb',help='Do not show backtrace when yade crashes (only effective with \-\-debug).',dest='noGdb',action='store_true',)
 par.disable_interspersed_args()
 
@@ -151,6 +152,11 @@
 	checksPath='${sourceRoot}'+'/scripts/test/checks' # replaced at install-time
 	execfile(checksPath+'/checkList.py')
 
+# Run performance check test
+if opts.performance:
+	checksPath='${sourceRoot}'+'/scripts/test/performance'
+	execfile(checksPath+'/checkPerf.py')
+
 def userSession(qt4=False,qapp=None):
 	# prepare nice namespace for users
 	import yade, yade.runtime

=== added directory 'scripts/test/performance'
=== added file 'scripts/test/performance/checkPerf.py'
--- scripts/test/performance/checkPerf.py	1970-01-01 00:00:00 +0000
+++ scripts/test/performance/checkPerf.py	2011-03-16 16:09:44 +0000
@@ -0,0 +1,125 @@
+# -*- coding: utf-8
+
+from yade import utils,pack,export,geom,timing,bodiesHandling
+import time,numpy
+	
+radRAD=[23.658,				#5000 elements
+	40.455,				#25000 elements
+	50.97,				#50000 elements
+	64.218,				#100000 elements
+	80.91]				#200000 elements
+	#109.811]			#500000 elements
+
+iterN=[12000,	#5000 elements
+	2500,				#25000 elements
+	1400,				#50000 elements
+	800,				#100000 elements
+	200]				#200000 elements
+	#10]			#500000 elements
+
+coefCor=[110,
+	28,
+	18,
+	9,
+	2]
+	#0.1]
+
+iterVel=[]
+testTime=[]
+particlesNumber=[]
+
+numberTests = 3
+
+tStartAll=time.time()
+
+for z in range(numberTests):
+	for i in range(len(radRAD)):
+		rR = radRAD[i]
+		nbIter=iterN[i]
+		O.reset()
+		
+		tc=0.001
+		en=.003
+		es=.003
+		frictionAngle=radians(35)
+		density=2300
+		
+		params=utils.getViscoelasticFromSpheresInteraction(tc,en,es)
+		defMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs
+		
+		O.dt=.1*tc # time step
+		rad=0.5 # particle radius
+		tolerance = 0.0001
+		
+		SpheresID=[]
+		SpheresID+=O.bodies.append(pack.regularHexa(pack.inSphere((Vector3(0.0,0.0,0.0)),rad),radius=rad/rR,gap=rad/rR*0.5,material=defMat))
+		
+		geometryParameters = bodiesHandling.spheresPackDimensions(SpheresID)
+		print len(SpheresID)
+		
+		floorId=[]
+		floorId+=O.bodies.append(geom.facetBox(geometryParameters['center'],geometryParameters['extends']/2.0*1.05,material=defMat)) #Floor
+		
+		#Calculate the mass of spheres
+		sphMass = utils.getSpheresVolume()*density
+		
+		# Create engines
+		O.engines=[
+			ForceResetter(),
+			InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
+			InteractionLoop(
+				[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
+				[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
+				[Law2_ScGeom_ViscElPhys_Basic()],
+			),
+			GravityEngine(gravity=[0,0,-9.81]),
+			NewtonIntegrator(damping=0),
+		]
+		
+		print "number of bodies %d"%len(O.bodies)
+		O.timingEnabled=True
+		tStart=time.time()
+		
+		O.run(nbIter)
+		O.wait()
+		
+		tEnd=time.time()
+		print
+		print 'Elapsed ', tEnd-tStart, ' sec'
+		print 'Performance ', nbIter/(tEnd-tStart), ' iter/sec'
+		print 'Extrapolation on 1e5 iters ', (tEnd-tStart)/nbIter*1e5/3600., ' hours'
+		print
+		timing.stats()
+		iterVel += [nbIter/(tEnd-tStart)]
+		testTime += [tEnd-tStart]
+		particlesNumber += [len(O.bodies)]
+
+
+tEndAll=time.time()
+commonTime = tEndAll-tStartAll
+
+print "Common time ", commonTime, "s"
+print
+print
+
+scoreIterVel=0.0
+for i in range(len(radRAD)):
+	iterAv=0.0
+	iterVelNumpy=numpy.empty(3)
+	for z in range(numberTests):
+		iterVelNumpy[z]=iterVel[z*len(radRAD)+i]
+	avgVel = numpy.average(iterVelNumpy)
+	dispVel = numpy.std(iterVelNumpy)/numpy.average(iterVelNumpy)*100.0
+	if (dispVel>10):
+		print "Calculation velocity is unstable, try to close all programs and start performance tests again"
+	
+	print particlesNumber[i]," spheres, velocity=",avgVel, "+-",dispVel,"%"
+	scoreIterVel+=avgVel/coefCor[i]*1000.0
+print
+print
+scoreIterVel = int(scoreIterVel)
+print scoreIterVel
+print "Number of threads ", os.environ['OMP_NUM_THREADS']
+print"___________________________________________________"
+print "CPU info", os.system('cat /proc/cpuinfo')
+sys.exit(0)