diff --git a/.travis.yml b/.travis.yml index 5fb242b..4cee540 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ language: node_js node_js: - - 0.6 - - 0.8 - 0.10 \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 678ce9a..e03bcf0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,6 +5,12 @@ module.exports = function (grunt) { child = require("child_process"); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + + exec: { + removeDocs: "rm -rf docs/* && mkdir -p ./docs/examples/browser && cp -r ./examples/browser/ ./docs/examples/browser && cp ./nools.min.js ./docs/nools.js", + createDocs: 'coddoc -f multi-html -d ./lib --dir ./docs' + }, + jshint: { src: ["./index.js", "lib/**/*.js", "Gruntfile.js"], options: { @@ -46,17 +52,33 @@ module.exports = function (grunt) { src: ['./browser/nools.js'], dest: './nools.js' } + }, + + benchmark: { + manners: { + files: "./benchmark/manners/benchmark.js" + }, + sendMoreMoney: { + files: "./benchmark/sendMoreMoney/benchmark.js" + }, + simple: { + files: "./benchmark/simple/benchmark.js" + }, + waltzDb: { + files: "./benchmark/waltzDb/benchmark.js" + } } }); // Default task. - grunt.registerTask('default', ['jshint', "compile-tests", 'it', 'browserify:nools', 'uglify:min']); + grunt.registerTask('default', ['jshint', "compile-tests", 'it', 'browserify:nools', 'uglify:min', 'exec']); grunt.loadNpmTasks('grunt-it'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-exec'); - grunt.registerTask("compile-tests", "compiles all lest files", function () { + grunt.registerTask("compile-tests", "compiles all nools files", function () { var files = grunt.file.expand("./test/rules/*.nools"), count = files.length, done = this.async(); function counter(err) { @@ -80,7 +102,20 @@ module.exports = function (grunt) { counter(err); }); }); + }); + grunt.registerTask("benchmarks", function () { + + }); + grunt.registerMultiTask('benchmark', 'execute it unit tests in a spawned process', function () { + var done = this.async(); + require(this.data.files).classic(function (err) { + if (err) { + done(false); + } else { + done(); + } + }); }); }; diff --git a/benchmark/manners/benchmark.js b/benchmark/manners/benchmark.js index 3bed7a0..6d3bf4d 100644 --- a/benchmark/manners/benchmark.js +++ b/benchmark/manners/benchmark.js @@ -1,16 +1,17 @@ -(function () { - "use strict"; - var data = require("./data"), - nools = require("../../index"); +"use strict"; +var data = require("./data"), + nools = require("../../index"); - var flow = nools.compile(__dirname + "/manners.nools"); - var guests = data.load(flow).manners64; - var session = flow.getSession.apply(flow, guests); - session.assert(new (flow.getDefined("count"))({value: 1})); - var start = new Date(); - session.match().then(function () { - console.log("Duration %dms", new Date() - start); - }, function (err) { - console.log(err.stack); - }); -})(); +var flow = nools.compile(__dirname + "/manners.nools"); +var guests = data.load(flow).manners64; +var session = flow.getSession.apply(flow, guests); +session.assert(new (flow.getDefined("count"))({value: 1})); +var start = new Date(); + +module.exports = session.match().then(function () { + console.log("Duration %dms", new Date() - start); + session.dispose(); +}, function (err) { + session.dispose(); + console.log(err.stack); +}); \ No newline at end of file diff --git a/benchmark/sendMoreMoney/benchmark.js b/benchmark/sendMoreMoney/benchmark.js index ba53640..a0ac5e3 100644 --- a/benchmark/sendMoreMoney/benchmark.js +++ b/benchmark/sendMoreMoney/benchmark.js @@ -6,7 +6,7 @@ var nools = require("../../index"), var start = new Date(), session; console.log("starting"); -(session = flow.getSession(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).match().then(function () { +module.exports = (session = flow.getSession(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).match().then(function () { console.log("%dms", +(new Date()) - start); session.dispose(); }); diff --git a/benchmark/simple/benchmark.js b/benchmark/simple/benchmark.js index 57a6501..e61da74 100644 --- a/benchmark/simple/benchmark.js +++ b/benchmark/simple/benchmark.js @@ -11,7 +11,7 @@ for (var i = 0; i < COUNT; i++) { } -var start = new Date().getTime(); +var start = new Date(); var execCount = 0; @@ -35,13 +35,12 @@ for (var j = 0; j < COUNT; j++) { } } -session.match(function (err) { +module.exports = session.match(function (err) { if (err) { throw err; } - var end = new Date().getTime(); - var diff = end - start; - console.log("elapsed: " + diff); + console.log("Duration %dms", new Date() - start); + session.dispose(); }); diff --git a/benchmark/waltzDb/benchmark.js b/benchmark/waltzDb/benchmark.js index 2546e99..7e3cefc 100644 --- a/benchmark/waltzDb/benchmark.js +++ b/benchmark/waltzDb/benchmark.js @@ -8,11 +8,12 @@ var items = data.load(flow).waltzdb4; var session = flow.getSession.apply(flow, items); session.assert(new (flow.getDefined("stage"))({value: "DUPLICATE"})); var start = new Date(); -session.match(function (err) { +module.exports = session.match(function (err) { if (err) { console.log(err.stack); } else { console.log("Duration %dms", new Date() - start); } + session.dispose(); }); diff --git a/docs/History.html b/docs/History.html index 1acb256..a791717 100644 --- a/docs/History.html +++ b/docs/History.html @@ -178,6 +178,16 @@ +

0.3.0

+

0.2.3