コード例 #1
0
 def test_calculate_filebyfile_success(self):
     filebyfile_size = apk_patch_size_estimator.calculate_filebyfile(
         'tests/1.zip', 'tests/2.zip', 'mypatch', '/tmp/patch.tmp')
     self.assertRegexpMatches(apk_patch_size_estimator.gzip_path, 'gzip')
     ## Using a delta of 0,01% to simply test
     self.assertAlmostEqual(filebyfile_size / float(2225377),
                            1,
                            delta=0.001)
     self.assertTrue(os.path.isfile('mypatch-file-by-file-patch.gz'))
     os.remove('mypatch-file-by-file-patch.gz')
 def test_calculate_filebyfile_success(self):
   filebyfile_size = apk_patch_size_estimator.calculate_filebyfile(
       'tests/1.zip',
       'tests/2.zip',
       'mypatch',
       '/tmp/patch.tmp')
   self.assertRegexpMatches(
       apk_patch_size_estimator.gzip_path, 'gzip')
   ## Using a delta of 0,01% to simply test
   self.assertAlmostEqual(filebyfile_size/float(2225377), 1, delta=0.001)
   self.assertTrue(os.path.isfile('mypatch-file-by-file-patch.gz'))
   os.remove('mypatch-file-by-file-patch.gz')
コード例 #3
0
def _PrintPatchSizeEstimate(new_apk, builder, bucket, report_func):
  apk_name = os.path.basename(new_apk)
  # Reference APK paths have spaces replaced by underscores.
  builder = builder.replace(' ', '_')
  old_apk = apk_downloader.MaybeDownloadApk(
      builder, apk_downloader.CURRENT_MILESTONE, apk_name,
      apk_downloader.DEFAULT_DOWNLOAD_PATH, bucket)
  if old_apk:
    # Use a temp dir in case patch size functions fail to clean up temp files.
    with build_utils.TempDir() as tmp:
      tmp_name = os.path.join(tmp, 'patch.tmp')
      bsdiff = apk_patch_size_estimator.calculate_bsdiff(
          old_apk, new_apk, None, tmp_name)
      report_func('PatchSizeEstimate', 'BSDiff (gzipped)', bsdiff, 'bytes')
      fbf = apk_patch_size_estimator.calculate_filebyfile(
          old_apk, new_apk, None, tmp_name)
      report_func('PatchSizeEstimate', 'FileByFile (gzipped)', fbf, 'bytes')
コード例 #4
0
ファイル: resource_sizes.py プロジェクト: cocos2d/v8
def _PrintPatchSizeEstimate(new_apk, builder, bucket, chartjson=None):
  apk_name = os.path.basename(new_apk)
  title = apk_name + '_PatchSizeEstimate'
  # Reference APK paths have spaces replaced by underscores.
  builder = builder.replace(' ', '_')
  old_apk = apk_downloader.MaybeDownloadApk(
      builder, apk_downloader.CURRENT_MILESTONE, apk_name,
      apk_downloader.DEFAULT_DOWNLOAD_PATH, bucket)
  if old_apk:
    # Use a temp dir in case patch size functions fail to clean up temp files.
    with build_utils.TempDir() as tmp:
      tmp_name = os.path.join(tmp, 'patch.tmp')
      bsdiff = apk_patch_size_estimator.calculate_bsdiff(
          old_apk, new_apk, None, tmp_name)
      ReportPerfResult(chartjson, title, 'BSDiff (gzipped)', bsdiff, 'bytes')
      fbf = apk_patch_size_estimator.calculate_filebyfile(
          old_apk, new_apk, None, tmp_name)
      ReportPerfResult(chartjson, title, 'FileByFile (gzipped)', fbf, 'bytes')