Created
May 5, 2016 00:42
-
-
Save mbebenita/ab2edf635c81351cf1054f40e3df23ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Copyright 2016 WebAssembly Community Group participants | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import os, shutil, sys, subprocess, difflib, json, time, urllib2, itertools | |
| import plotly | |
| import plotly.graph_objs as go | |
| import pprint | |
| import locale | |
| locale.setlocale(locale.LC_ALL, 'en_US') | |
| import scripts.storage | |
| import scripts.support | |
| warnings = [] | |
| files = [ | |
| 'bb.wast' | |
| ] | |
| kindNames = [] | |
| origSizes = [] | |
| lzmaSizes = [] | |
| gzipSizes = [] | |
| for file in files: | |
| print '\n[ processing file ' + file + ' ]\n' | |
| args = [os.path.join('bin', 'wasm-as'), file] | |
| opts = ['--optimize'] | |
| for k in range(0, len(opts) + 1): | |
| for opt in itertools.combinations(opts, k): | |
| argz = args + list(opt) | |
| kindNames.append(" ".join(opt)) | |
| # print args + list(opt) | |
| print "Assemble file." | |
| proc = subprocess.Popen(argz, stdout=open('out.bin', 'w'), stderr=subprocess.PIPE) | |
| out, err = proc.communicate() | |
| assert proc.returncode == 0, err | |
| origSize = os.stat('out.bin').st_size | |
| origSizes.append(origSize); | |
| print "Lzma" | |
| proc = subprocess.Popen(['lzma', '-k', '-f', 'out.bin'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| out, err = proc.communicate() | |
| assert proc.returncode == 0, err | |
| lzmaSize = os.stat('out.bin.lzma').st_size | |
| lzmaSizes.append(lzmaSize) | |
| print "Gzip" | |
| proc = subprocess.Popen(['gzip', '-k', '-f', 'out.bin'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| out, err = proc.communicate() | |
| assert proc.returncode == 0, err | |
| gzSize = os.stat('out.bin.gz').st_size | |
| gzipSizes.append(gzSize) | |
| def formatNumber(n): | |
| return locale.format("%d", n, grouping=True) | |
| print "Configuration | Original | X | Lzma | X | Gzip | X " | |
| print "---------------- | ---------------- | ----- | ---------------- | ----- | ---------------- | ----- " | |
| for i in range(len(kindNames)): | |
| print "{:16} | {:16} | {:.3f} | {:16} | {:.3f} | {:16} | {:.3f}".format(kindNames[i], | |
| formatNumber(origSizes[i]), float(origSizes[i]) / origSizes[0], | |
| formatNumber(lzmaSizes[i]), float(lzmaSizes[i]) / lzmaSizes[0], | |
| formatNumber(gzipSizes[i]), float(gzipSizes[i]) / gzipSizes[0]) | |
| if warnings: | |
| print '\n' + '\n'.join(warnings) |
Author
Author
With '-9'
| Configuration | Original | X | Lzma | X | Gzip | X |
|---|---|---|---|---|---|---|
| 2,312,317 | 1.000 | 554,109 | 1.000 | 768,167 | 1.000 | |
| --optimize | 1,507,749 | 0.652 | 615,700 | 1.111 | 731,866 | 0.953 |
Author
| Configuration | Original | x | Lzma | x | Gzip | X | Brotli | x |
|---|---|---|---|---|---|---|---|---|
| 2,312,317 | 1.000 | 554,109 | 1.000 | 768,167 | 1.000 | 581,158 | 1.000 | |
| --optimize | 1,507,749 | 0.652 | 615,700 | 1.111 | 731,866 | 0.953 | 632,756 | 1.089 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BB.wast