Changeset 1e7de38 in sasview for sansmodels/src/sans/models


Ignore:
Timestamp:
Oct 4, 2010 12:53:10 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
9ec4406
Parents:
d267aed
Message:

added time test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/test/utest_model_sphereexpshell.py

    ra1b2471 r1e7de38  
    1515        from sans.models.CoreMultiShellModel import CoreMultiShellModel 
    1616        from sans.models.VesicleModel import VesicleModel  
    17  
    18         self.model = SphereExpShellModel(n_shells=1) 
    19         self.model2 = SphereExpShellModel(n_shells=1).model 
    20         self.model3 = CoreMultiShellModel(n_shells=1) 
     17         
     18        # intit models and the multifactor 
     19        self.model = SphereExpShellModel(1) 
     20        self.model2 = SphereExpShellModel(1).model 
     21        self.model3 = CoreMultiShellModel(1) 
    2122        self.model4 = VesicleModel() 
     23        self.model5 = SphereExpShellModel(9) 
    2224         
    2325    def test_compare_Exp0_flat(self): 
     
    5355    def test_compare_Exp0_flat_vesicle(self): 
    5456        """ 
    55         Check if Exp function with A_shell=0 gives the same value as Flat function of vesicle model when sld_solv=sld_core 
     57        Check if Exp function with A_shell=0 gives the same value as Flat  
     58        function of vesicle model when sld_solv=sld_core 
    5659        """ 
    57         print "\n*****Note: All tests (test_compare_Exp0_flat and test_compare_Expsmall_line) were passes since Sept. 18, 2010..." 
     60        print "\n*****Note: All tests (test_compare_Exp0_flat and \ 
     61            test_compare_Expsmall_line) were passes since Sept. 18, 2010..." 
    5862        # Exp: func_shell = 2, Line: func_shell =1 , Flat: func_shell = 0. 
    5963        # A_shell = The coefficient of the exponential function: exp(A_shell*(r-ro)/thick_shell) 
     
    9094    def test_compare_Expsmall_line(self): 
    9195        """ 
    92         Check if Exp function with A_shell-->0 gives the same value as linear function 
     96        Check if Exp function with A_shell-->0 gives the same value  
     97        as a linear function 
    9398        """ 
    9499        # exp function crosses over to line func as A_shell-->0 
     
    101106        self.assertAlmostEqual(self.model.run(0.1),self.model2.run(0.1),4) 
    102107         
     108    def test_compare_time_linear_flat_functions(self): 
     109        """ 
     110        Compare the calculation time between func=1(linear) , and 2 (step). 
     111        """ 
     112        from time import time 
     113        # using linear func 
     114        self.model5.model.setParam("func_shell1", 1) 
     115        #input 
     116        input = [0.01,0.01] 
     117        st = time() 
     118        for iter in range(0,100000): 
     119            self.model5.model.run(0.01) 
     120        time_linear = time()-st 
     121         
     122        # using flat function 
     123        self.model5.model.setParam("func_shell1", 0) 
     124        st = time() 
     125        for iter in range(0,100000): 
     126            self.model5.model.run(0.01) 
     127        time_flat = time()-st 
     128         
     129        print "time (linear) = %s, \n time (flat) = %s"% (time_linear,time_flat) 
     130         
     131        #Compare time of the calculation: time_linear takes a bit longer 
     132        # but they are not much different   
     133        self.assertAlmostEqual(time_linear,time_flat,0) 
    103134   
    104135                 
Note: See TracChangeset for help on using the changeset viewer.