@@ -56,17 +56,17 @@ async def _launch_macrobenchmark_test(build_only):
56
56
_logger .info (f'Artifact versions: { artifact_versions } ' )
57
57
58
58
test_dir = await _prepare_test_directory ()
59
- _logger .info (f'Test app directory : { test_dir } ' )
59
+ _logger .info (f'Directory for test apps : { test_dir } ' )
60
60
61
61
config = await _process_config_yaml ()
62
62
_logger .info (f'Processed yaml configurations: { config } ' )
63
63
64
64
tests = [MacrobenchmarkTest (app , artifact_versions , os .getcwd (), test_dir ) for app in config ['test-apps' ]]
65
65
66
66
_logger .info (f'Building { len (tests )} macrobenchmark test apps...' )
67
- # TODO(yifany): investigate why it runs significantly slower
68
- # - on corp workstations than M1 macbook pro
69
- # - with gradle 7.5.1 than gradle 6.9.2
67
+ # TODO(yifany): investigate why it is much slower with asyncio.gather
68
+ # - on corp workstations (10 min) than M1 macbook pro (3 min)
69
+ # - with gradle 7.5.1 (10 min) than gradle 6.9.2 (5 min)
70
70
# await asyncio.gather(*[x.build() for x in tests])
71
71
for test in tests :
72
72
await test .build ()
@@ -102,12 +102,12 @@ async def _process_config_yaml():
102
102
app ['traces' ].extend (config ['common-traces' ])
103
103
104
104
# Adding an empty android app for baseline comparison
105
- config ['test-apps' ].append ( {'sdk' : 'baseline' , 'name' : 'baseline' })
105
+ config ['test-apps' ].insert ( 0 , {'sdk' : 'baseline' , 'name' : 'baseline' })
106
106
return config
107
107
108
108
109
109
async def _prepare_test_directory ():
110
- test_dir = tempfile .mkdtemp (prefix = 'test-run -' )
110
+ test_dir = tempfile .mkdtemp (prefix = 'benchmark-test -' )
111
111
112
112
# Required as the dir is not defined in the root settings.gradle
113
113
open (os .path .join (test_dir , 'settings.gradle' ), 'w' ).close ()
@@ -172,25 +172,29 @@ async def _create_benchmark_projects(self):
172
172
app_name = self .test_app_config ['name' ]
173
173
self .logger .info (f'Creating test app "{ app_name } "...' )
174
174
175
- mustache_context = await self ._prepare_mustache_context ()
176
-
175
+ self .logger .info (f'Copying project template files into "{ self .test_app_dir } "...' )
177
176
template_dir = os .path .join (self .repo_root_dir , 'health-metrics/benchmark/template' )
178
177
shutil .copytree (template_dir , self .test_app_dir )
178
+
179
+ self .logger .info (f'Copying gradle wrapper binary into "{ self .test_app_dir } "...' )
180
+ shutil .copy (os .path .join (self .test_dir , 'gradlew' ), self .test_app_dir )
181
+ shutil .copy (os .path .join (self .test_dir , 'gradlew.bat' ), self .test_app_dir )
182
+ shutil .copytree (os .path .join (self .test_dir , 'gradle' ), os .path .join (self .test_app_dir , 'gradle' ))
183
+
179
184
with chdir (self .test_app_dir ):
185
+ mustache_context = await self ._prepare_mustache_context ()
180
186
renderer = pystache .Renderer ()
181
187
mustaches = glob .glob ('**/*.mustache' , recursive = True )
182
188
for mustache in mustaches :
183
- self .logger .info (f'Processing mustache template: { mustache } ... ' )
189
+ self .logger .info (f'Processing template file : { mustache } ' )
184
190
result = renderer .render_path (mustache , mustache_context )
185
191
original_name = mustache .removesuffix ('.mustache' )
186
192
with open (original_name , 'w' ) as file :
187
193
file .write (result )
188
194
189
195
async def _assemble_benchmark_apks (self ):
190
- executable = './gradlew'
191
- args = ['assemble' , '--project-dir' , self .test_app_dir ]
192
- with chdir (self .test_dir ):
193
- await self ._exec_subprocess (executable , args )
196
+ with chdir (self .test_app_dir ):
197
+ await self ._exec_subprocess ('./gradlew' , ['assemble' ])
194
198
195
199
async def _execute_benchmark_tests (self ):
196
200
self .logger .debug (glob .glob (f'{ self .test_app_dir } /**/*.apk' , recursive = True ))
0 commit comments