@@ -19,20 +19,83 @@ def setup_class(cls):
1919 _Director .set_default_production ('Bench.Production' )
2020 # start the production
2121 _Director .start_production ()
22+ # create a list of results
23+ cls .results = []
24+
25+ def test_bench_iris (self ):
26+ # this test is made to preload the production
27+ _Director .test_component ('Python.BenchIoPProcess' )
28+
2229
2330 def test_bench_iris_message (self ):
2431 body = "test"
2532 result = timeit .timeit (lambda : _Director .test_component ('Python.BenchIoPProcess' ,'' ,'iris.Ens.StringRequest' ,body ), number = 1 )
26- # print the time in pytest output
27- print (f"Time: { result } " )
33+ # set the result in the list
34+ name = 'Python BP to Python BO with Iris Message'
35+ self .results .append ((name ,result ))
36+ # assert the result
37+ assert result > 0
38+
39+ def test_bench_iris_message_to_cls (self ):
40+ body = "test"
41+ result = timeit .timeit (lambda : _Director .test_component ('Python.BenchIoPProcess.To.Cls' ,'' ,'iris.Ens.StringRequest' ,body ), number = 1 )
42+ # set the result in the list
43+ name = 'Python BP to ObjetScript BO with Iris Message'
44+ self .results .append ((name ,result ))
2845 # assert the result
2946 assert result > 0
3047
3148 def test_bench_python_message (self ):
32- body = "test" * 200000
49+ body = "test"
3350 result = timeit .timeit (lambda : _Director .test_component ('Python.BenchIoPProcess' ,'' ,'msg.MyMessage' ,f'{{"message":"{ body } "}}' ), number = 1 )
34- # print the time in pytest output
35- print (f"Time: { result } " )
51+ # set the result in the list
52+ name = 'Python BP to Python BO with Python Message'
53+ self .results .append ((name ,result ))
54+ # assert the result
55+ assert result > 0
56+
57+ def test_bench_python_message_to_cls (self ):
58+ body = "test"
59+ result = timeit .timeit (lambda : _Director .test_component ('Python.BenchIoPProcess.To.Cls' ,'' ,'msg.MyMessage' ,f'{{"message":"{ body } "}}' ), number = 1 )
60+ # set the result in the list
61+ name = 'Python BP to ObjetScript BO with Python Message'
62+ self .results .append ((name ,result ))
63+ # assert the result
64+ assert result > 0
65+
66+ def test_bench_cls_iris_message (self ):
67+ body = "test"
68+ result = timeit .timeit (lambda : _Director .test_component ('Bench.Process' ,'' ,'iris.Ens.StringRequest' ,body ), number = 1 )
69+ # set the result in the list
70+ name = 'ObjetScript BP to Python BO with Iris Message'
71+ self .results .append ((name ,result ))
72+ # assert the result
73+ assert result > 0
74+
75+ def test_bench_cls_iris_message_to_cls (self ):
76+ body = "test"
77+ result = timeit .timeit (lambda : _Director .test_component ('Bench.Process.To.Cls' ,'' ,'iris.Ens.StringRequest' ,body ), number = 1 )
78+ # set the result in the list
79+ name = 'ObjetScript BP to ObjetScript BO with Iris Message'
80+ self .results .append ((name ,result ))
81+ # assert the result
82+ assert result > 0
83+
84+ def test_bench_cls_python_message (self ):
85+ body = "test"
86+ result = timeit .timeit (lambda : _Director .test_component ('Bench.Process' ,'' ,'msg.MyMessage' ,f'{{"message":"{ body } "}}' ), number = 1 )
87+ # set the result in the list
88+ name = 'ObjetScript BP to Python BO with Python Message'
89+ self .results .append ((name ,result ))
90+ # assert the result
91+ assert result > 0
92+
93+ def test_bench_cls_python_message_to_cls (self ):
94+ body = "test"
95+ result = timeit .timeit (lambda : _Director .test_component ('Bench.Process.To.Cls' ,'' ,'msg.MyMessage' ,f'{{"message":"{ body } "}}' ), number = 1 )
96+ # set the result in the list
97+ name = 'ObjetScript BP to ObjetScript BO with Python Message'
98+ self .results .append ((name ,result ))
3699 # assert the result
37100 assert result > 0
38101
@@ -43,3 +106,8 @@ def teardown_class(cls):
43106 _Director .stop_production ()
44107 # set the default production
45108 _Director .set_default_production ('test' )
109+ # write the results in a file
110+ current_dir = os .path .dirname (os .path .abspath (__file__ ))
111+ with open (os .path .join (current_dir ,'bench' ,'result.txt' ),'w' ) as f :
112+ for name ,result in cls .results :
113+ f .write (f'{ name } : { result } \n ' )
0 commit comments