mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-25 22:50:42 +03:00
remove built in benchmarking options for now
This commit is contained in:
parent
d1cf102979
commit
9922ab2a94
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "elm-optimize-level-2",
|
"name": "elm-optimize-level-2",
|
||||||
"description": "A second level of optimization for the Javascript that the Elm Compiler produces.",
|
"description": "A second level of optimization for the Javascript that the Elm Compiler produces.",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@ -58,10 +58,10 @@
|
|||||||
"ts-node": "^8.10.2",
|
"ts-node": "^8.10.2",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
"uglify-js": "^3.10.0",
|
"uglify-js": "^3.10.0",
|
||||||
"v8-natives": "^1.2.5"
|
"v8-natives": "^1.2.5",
|
||||||
|
"@types/selenium-webdriver": "^4.0.14"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/selenium-webdriver": "^4.0.14",
|
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"commander": "^6.0.0",
|
"commander": "^6.0.0",
|
||||||
"node-elm-compiler": "^5.0.4",
|
"node-elm-compiler": "^5.0.4",
|
||||||
|
79
src/index.ts
79
src/index.ts
@ -2,15 +2,14 @@
|
|||||||
import program from 'commander';
|
import program from 'commander';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as Transform from './transform';
|
import * as Transform from './transform';
|
||||||
import { toolDefaults, benchmarkDefaults, Browser} from './types';
|
import { toolDefaults } from './types';
|
||||||
import { compileToStringSync } from 'node-elm-compiler';
|
import { compileToStringSync } from 'node-elm-compiler';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
const { version } = require('../package.json');
|
const { version } = require('../package.json');
|
||||||
import * as BenchInit from './benchmark/init'
|
// import * as BenchInit from './benchmark/init'
|
||||||
import * as Benchmark from './benchmark/benchmark';
|
// import * as Benchmark from './benchmark/benchmark';
|
||||||
import * as Reporting from './benchmark/reporting';
|
// import * as Reporting from './benchmark/reporting';
|
||||||
import { readFilesSync } from './fs_util';
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.version(version)
|
.version(version)
|
||||||
@ -28,9 +27,9 @@ Give me an Elm file, I'll compile it behind the scenes using Elm 0.19.1, and the
|
|||||||
.usage('[options] <src/Main.elm>')
|
.usage('[options] <src/Main.elm>')
|
||||||
.option('--output <output>', 'the javascript file to create.', 'elm.js')
|
.option('--output <output>', 'the javascript file to create.', 'elm.js')
|
||||||
.option('-O3, --optimize-speed', 'Enable optimizations that likely increases asset size', false)
|
.option('-O3, --optimize-speed', 'Enable optimizations that likely increases asset size', false)
|
||||||
.option('--init-benchmark <dir>', 'Generate some files to help run benchmarks')
|
// .option('--init-benchmark <dir>', 'Generate some files to help run benchmarks')
|
||||||
.option('--benchmark <dir>', 'Run the benchmark in the given directory.')
|
// .option('--benchmark <dir>', 'Run the benchmark in the given directory.')
|
||||||
.option('--replacements <dir>', 'Replace stuff')
|
// .option('--replacements <dir>', 'Replace stuff')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
async function run(inputFilePath: string | undefined) {
|
async function run(inputFilePath: string | undefined) {
|
||||||
@ -39,41 +38,41 @@ async function run(inputFilePath: string | undefined) {
|
|||||||
let elmFilePath = undefined;
|
let elmFilePath = undefined;
|
||||||
|
|
||||||
const options = program.opts();
|
const options = program.opts();
|
||||||
const replacements = options.replacements;
|
const replacements = null;
|
||||||
const o3Enabled = options.optimizeSpeed;
|
const o3Enabled = options.optimizeSpeed;
|
||||||
|
|
||||||
if (program.initBenchmark) {
|
// if (program.initBenchmark) {
|
||||||
console.log(`Initializing benchmark ${program.initBenchmark}`)
|
// console.log(`Initializing benchmark ${program.initBenchmark}`)
|
||||||
BenchInit.generate(program.initBenchmark)
|
// BenchInit.generate(program.initBenchmark)
|
||||||
process.exit(0)
|
// process.exit(0)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (program.benchmark) {
|
// if (program.benchmark) {
|
||||||
const options = {
|
// const options = {
|
||||||
compile: true,
|
// compile: true,
|
||||||
gzip: true,
|
// gzip: true,
|
||||||
minify: true,
|
// minify: true,
|
||||||
verbose: true,
|
// verbose: true,
|
||||||
assetSizes: true,
|
// assetSizes: true,
|
||||||
runBenchmark: [
|
// runBenchmark: [
|
||||||
{
|
// {
|
||||||
browser: Browser.Chrome,
|
// browser: Browser.Chrome,
|
||||||
headless: true,
|
// headless: true,
|
||||||
}
|
// }
|
||||||
],
|
// ],
|
||||||
transforms: benchmarkDefaults(o3Enabled, replacements),
|
// transforms: benchmarkDefaults(o3Enabled, replacements),
|
||||||
};
|
// };
|
||||||
const report = await Benchmark.run(options, [
|
// const report = await Benchmark.run(options, [
|
||||||
{
|
// {
|
||||||
name: 'Benchmark',
|
// name: 'Benchmark',
|
||||||
dir: program.benchmark,
|
// dir: program.benchmark,
|
||||||
elmFile: 'V8/Benchmark.elm',
|
// elmFile: 'V8/Benchmark.elm',
|
||||||
}
|
// }
|
||||||
]);
|
// ]);
|
||||||
console.log(Reporting.terminal(report));
|
// console.log(Reporting.terminal(report));
|
||||||
// fs.writeFileSync('./results.markdown', Reporting.markdownTable(result));
|
// // fs.writeFileSync('./results.markdown', Reporting.markdownTable(result));
|
||||||
process.exit(0)
|
// process.exit(0)
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (inputFilePath && inputFilePath.endsWith('.js')) {
|
if (inputFilePath && inputFilePath.endsWith('.js')) {
|
||||||
jsSource = fs.readFileSync(inputFilePath, 'utf8');
|
jsSource = fs.readFileSync(inputFilePath, 'utf8');
|
||||||
|
Loading…
Reference in New Issue
Block a user