-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor fixes #2
Minor fixes #2
Conversation
Benchmark is a library used for benchmarking the performance of scripts and tools, and it wouldn't make much sense to have the final user install it along with the module.
Esprima and/or acorn can be optionally installed to have a complete overview of the tools' speed.
Moved `sources/` to `bench/sources/`, also renamed `speed.js` to `bench/index.js`. This way everything that is related to benchmarking is located in a separate folder and benches can be run with `node bench` (or `npm run bench`). The bench runner (`speed.js`) has undergone some major refactoring. While keeping the same features, modularity and result reporting have been improved. Everything starting line #84 is completely optional.
@zenekron
Hmm; I've been considering this for some time now, and I totally agree with you the readability will improve if I do so, but I'm also very eager to keep it "browser-friendly", and I have fears splitting it into several smaller pieces might be against that goal. I'd be very glad to know your opinions on this; I'd also be more than glad to give you push access immediately if you find it appropriate. |
@icefapper Anyhow good solutions would be browserify to prepare a browser version and uglify to minify it. Before messing with any of those you should refactor the whole code to be modular. NamespacesIn plain javascript, to define a "namespace" you would do something like: ;(function(import1, import2, import3, exports) {
exports.test = function() { ... }
....
})(lib1, lib2, lib3, myObject); This works and is perfectly fine, but in Node there is a better way to handle them:
Keeping in mind these three points, the same code as above would look like: var import1 = require('lib1');
var import2 = require('lib2');
var import3 = require('lib3');
function test() { ...}
module.exports = {
test: test,
} I'm saying this because in order to have modules behave correctly, you have to adopt this second syntax, which is not what you did in You really should focus on writing lube to run correctly on node, then let tools like browserify produce a browser build. |
@zenekron Thanks! Also, I wrote a dirty (as always) build script for sewing that abominable mess back together :) Once again, I would be glad to know if I'm allowed to give you push access. Thank for all the help. |
Dependencies
benchmark
from dependencies in favor of devDependenciesmicrotime
for better benchmark reportsacorn
andesprima
as optionalDependenciesBenchmarks
Everything related to benchmarking has been moved to a
bench
folder. The originalspeed.js
has undergone some refactoring and can now be found atbench/index.js
. The output of the benchmarks is now stored in aresults
object which can be easily manipulated to extract desired data.Default reporter
Notes
With the resolution of #5900,
engine.nodes
should be changed again to*
or whatever version of the engine this package should support.For testing some users suggested the use of tape. I tried myself a
mocha
+chai
+istanbul
combo and they work pretty well together and help keeping the codebase sane.I really suggest you to split
lube.js
in different files to improve readability and maintainability.