From 3cb508ec79690565988005df9bd0b7af8059fb01 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sat, 21 Mar 2015 18:43:40 -0400 Subject: [PATCH] Clear out unneeded files --- .dygraph-combined-clean.js | 7 -- Makefile | 50 ----------- NOTES | 37 --------- closure-todo.txt | 46 ---------- compile-with-closure.sh | 49 ----------- data.js | 63 -------------- gadget.xml | 119 -------------------------- generate-combined.sh | 87 ------------------- generate-jar.sh | 4 - jsTestDriver.conf | 34 -------- phantom-driver.js | 203 --------------------------------------------- phantom-perf.js | 94 --------------------- 12 files changed, 793 deletions(-) delete mode 100644 .dygraph-combined-clean.js delete mode 100644 Makefile delete mode 100644 NOTES delete mode 100644 closure-todo.txt delete mode 100755 compile-with-closure.sh delete mode 100644 data.js delete mode 100644 gadget.xml delete mode 100755 generate-combined.sh delete mode 100755 generate-jar.sh delete mode 100644 jsTestDriver.conf delete mode 100644 phantom-driver.js delete mode 100644 phantom-perf.js diff --git a/.dygraph-combined-clean.js b/.dygraph-combined-clean.js deleted file mode 100644 index e6380de..0000000 --- a/.dygraph-combined-clean.js +++ /dev/null @@ -1,7 +0,0 @@ -This is not the file you are looking for. -A reasonably up-to-date version can be found at http://dygraphs.com/dygraph-combined.js - -dygraph-combined.js is a "packed" version of the larger dygraphs JS files. It is -smaller and loads more quickly, but is harder to debug. - -To generate this file, run "make" or generate-combined.sh. diff --git a/Makefile b/Makefile deleted file mode 100644 index 6cddafa..0000000 --- a/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# You should run "npm install" before running any commands in this Makefile. - -all: test generate-combined generate-documentation - -clean: - @echo cleaning... - @cp .dygraph-combined-clean.js dygraph-combined.js - rm -f docs/options.html - -generate-combined: - @echo Generating dygraph-combined.js - @./generate-combined.sh - -generate-documentation: - @echo Generating docs/options.html - @./generate-documentation.py > docs/options.html - @chmod a+r docs/options.html - -gwt: generate-gwt - -generate-gwt: - @echo Generating GWT JAR file - @./generate-jar.sh - -test: - @./test.sh - @./check-combined-unaffected.sh - -test-combined: move-combined test clean-combined-test - -move-combined: generate-combined - mv dygraph-combined.js dygraph-autoloader.js - -clean-combined-test: clean - @echo restoring combined - git checkout dygraph-autoloader.js - rm dygraph-combined.js.map - -lint: - @./generate-combined.sh ls \ - | grep -v 'polyfills' \ - | xargs ./node_modules/.bin/jshint - -# Commands to run for continuous integration on Travis-CI -travis: test test-combined lint - -publish: - ./generate-combined.sh - npm publish - git checkout dygraph-combined.js diff --git a/NOTES b/NOTES deleted file mode 100644 index 211f59a..0000000 --- a/NOTES +++ /dev/null @@ -1,37 +0,0 @@ -Axis-related properties: -includeZero -valueRange -labelsKMB -labelsKMG2 -pixelsPerYLabel -yAxisLabelWidth -axisLabelFontSize -axisTickSize - -How is the y-axis determined? - -Dygraph.numericTicks: min, max -> set of ticks for axis -tick = { label: label, v: value } - -addYTicks_: min, max -> void -sets the yAxis and yTicks properties of layout_ - -drawGraph_: -if set, uses this.valueRange_ ([low, high] array) - -> adds ticks via addYTicks_ - -> sets displayedYRange_ - -otherwise, calculates a good axis based on minY and maxY. - -this.displayedYRange_ is returned by the yAxisRange function. -this is, in turn, used by the toDataCoords and toDomCoords methods. - -Path of least resistance: -- in drawGraph_, calculate [minY, maxY] per-series -- write a function to compute y-axes for all series, ensure only two axes. -- make yAxis, yTicks into arrays in layout_ -- add a series -> axis mapping to layout_, dygraph -- add code to Renderer to add second axis. -- add optional 'series' parameter to toDomCoords/toDataCoords - -This won't be compatible with stacked charts. diff --git a/closure-todo.txt b/closure-todo.txt deleted file mode 100644 index ae77622..0000000 --- a/closure-todo.txt +++ /dev/null @@ -1,46 +0,0 @@ -Many of the functions and methods in the dygraphs source have some form of -Closure annotations on them ("@param", "@return", "@private", etc.). - -These provide some documentation value, but they were largely written by -developers who had never used the Closure Compiler and so the syntax is -often not quite correct. - -This file tracks which files have been fully "closurized", i.e. compile -under the Closure Compiler without any errors or warnings. - -Core: -- dygraph-canvas.js -- dygraph-interaction-model.js -- dygraph-layout.js -x dygraph-options.js -- dygraph.js -x dygraph-gviz.js -x dygraph-tickers.js -x dygraph-options-reference.js -x dygraph-utils.js -x dashed-canvas.js -- dygraph-plugin-base.js -- dygraph-plugin-install.js - -Plugins: -- plugins/annotations.js -- plugins/axes.js -- plugins/chart-labels.js -- plugins/grid.js -- plugins/legend.js -- plugins/range-selector.js - -Datahandler: -- datahandler/bars-custom.js -- datahandler/bars-error.js -- datahandler/bars-fractions.js -- datahandler/bars.js -- datahandler/datahandler.js -- datahandler/default-fractions.js -- datahandler/default.js - -Here's a command that can be used to build dygraphs using the closure -compiler: -java -jar ../../closure-compiler-read-only/build/compiler.jar --js=dygraph-utils.js --js=dashed-canvas.js --js=dygraph-options-reference.js --js=dygraph-tickers.js --js=dygraph-gviz.js --js=dygraph-options.js --js_output_file=/tmp/out.js --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE --externs dygraph-externs.js - -As each file is closurized, it can be added as a "--js" parameter. diff --git a/compile-with-closure.sh b/compile-with-closure.sh deleted file mode 100755 index 90d9d9a..0000000 --- a/compile-with-closure.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# This script runs dygraphs through the Closure Compiler. This checks for -# errors (both in the JS and in the jsdoc) and flags type errors as WARNINGS. - -# It outputs minified JS to a temp file. This should be ignored for now, until -# it's fully functional. - -CLOSURE_COMPILER=node_modules/closure-compiler/lib/vendor/compiler.jar -BASE_JS=node_modules/obvious-closure-library/closure/goog/base.js -if [[ (! -f $CLOSURE_COMPILER) || (! -f $BASE_JS) ]]; then - echo "Missing compiler.jar or base.js. Try running 'npm install'." 1>&2 - exit 1 -fi - -java -jar $CLOSURE_COMPILER \ - --compilation_level ADVANCED_OPTIMIZATIONS \ - --warning_level VERBOSE \ - --output_wrapper='(function() {%output%})();' \ - --js $BASE_JS \ - --js=dashed-canvas.js \ - --js=dygraph-options.js \ - --js=dygraph-layout.js \ - --js=dygraph-canvas.js \ - --js=dygraph.js \ - --js=dygraph-utils.js \ - --js=dygraph-gviz.js \ - --js=dygraph-interaction-model.js \ - --js=dygraph-tickers.js \ - --js=dygraph-plugin-base.js \ - --js=plugins/annotations.js \ - --js=plugins/axes.js \ - --js=plugins/chart-labels.js \ - --js=plugins/grid.js \ - --js=plugins/legend.js \ - --js=plugins/range-selector.js \ - --js=dygraph-plugin-install.js \ - --js=dygraph-options-reference.js \ - --js=datahandler/datahandler.js \ - --js=datahandler/default.js \ - --js=datahandler/default-fractions.js \ - --js=datahandler/bars.js \ - --js=datahandler/bars-custom.js \ - --js=datahandler/bars-error.js \ - --js=datahandler/bars-fractions.js \ - --js=dygraph-exports.js \ - --externs dygraph-internal.externs.js \ - --externs gviz-api.js \ - --js_output_file=/tmp/out.js diff --git a/data.js b/data.js deleted file mode 100644 index d92a633..0000000 --- a/data.js +++ /dev/null @@ -1,63 +0,0 @@ -function StubbedData() { -return "" + -"Date,A,B\n" + -"20061001,3.01953818828,0.7212041046,2.18487394958,0.599318549691\n" + -"20061002,3.63321799308,0.778297234566,1.69491525424,0.531417655826\n" + -"20061003,2.44328097731,0.644967734352,2.51256281407,0.640539070386\n" + -"20061004,3.52733686067,0.774700921683,2.68456375839,0.66207105053\n" + -"20061005,3.28719723183,0.741636245748,2.35294117647,0.621407707226\n" + -"20061006,1.58450704225,0.523967868159,3.78657487091,0.791868460623\n" + -"20061007,5.32859680284,0.946589405904,4.0404040404,0.807910739509\n" + -"20061008,2.64084507042,0.672799548916,2.37288135593,0.626609885481\n" + -"20061009,2.26480836237,0.620990945917,3.5413153457,0.75897176848\n" + -"20061010,3.29289428076,0.74289969528,2.02702702703,0.579191340004\n" + -"20061011,2.7633851468,0.681234043829,1.1744966443,0.4413034044\n" + -"20061012,3.28719723183,0.741636245748,3.37268128162,0.741327769578\n" + -"20061013,1.77304964539,0.55569466381,1.85810810811,0.555011329732\n" + -"20061014,3.39892665474,0.7664008338,1.67224080268,0.524368852929\n" + -"20061015,2.65017667845,0.675144574777,3.35570469799,0.737661045752\n" + -"20061016,3.63951473137,0.779620631266,2.34899328859,0.620377617453\n" + -"20061017,2.25694444444,0.618859623032,1.68067226891,0.526990133716\n" + -"20061018,4.47504302926,0.857766274964,2.51677852349,0.641599927369\n" + -"20061019,2.44755244755,0.646081155692,1.68067226891,0.526990133716\n" + -"20061020,3.67775831874,0.787656442774,3.066439523,0.711598843969\n" + -"20061021,3.94265232975,0.823839169829,3.85906040268,0.788990618726\n" + -"20061022,2.59067357513,0.660187558973,3.71621621622,0.777438794254\n" + -"20061023,4.33275563258,0.847570482324,3.85906040268,0.788990618726\n" + -"20061024,3.10344827586,0.720049610821,2.84280936455,0.679611549697\n" + -"20061025,1.40350877193,0.492720767725,2.7027027027,0.666482380968\n" + -"20061026,1.95035460993,0.582291234145,2.36486486486,0.624518599275\n" + -"20061027,2.30905861456,0.632980642182,2.03045685279,0.580161203819\n" + -"20061028,4.09252669039,0.835706590809,2.87648054146,0.68754192469\n" + -"20061029,2.66903914591,0.679883997626,2.02360876897,0.578224712918\n" + -"20061030,4.74516695958,0.89127787497,4.36241610738,0.836670992529\n" + -"20061031,2.78260869565,0.685905251933,3.20945945946,0.724388507178\n" + -"20061101,1.5873015873,0.524884521441,1.51260504202,0.500373860545\n" + -"20061102,2.78745644599,0.687083077461,2.0202020202,0.57726130639\n" + -"20061103,5.11463844797,0.925157232782,2.68907563025,0.663168401088\n" + -"20061104,4.9001814882,0.919644816432,3.07692307692,0.713993047527\n" + -"20061105,5.13274336283,0.928343545136,3.55329949239,0.761492892041\n" + -"20061106,1.92644483363,0.575222935029,2.35294117647,0.621407707226\n" + -"20061107,2.46478873239,0.650573541306,1.52027027027,0.502889967904\n" + -"20061108,2.13523131673,0.609772022763,2.6981450253,0.665374048085\n" + -"20061109,3.88007054674,0.811026422222,2.72572402044,0.672079879106\n" + -"20061110,2.63620386643,0.671633132526,3.71621621622,0.777438794254\n" + -"20061111,3.69718309859,0.791736755355,3.0303030303,0.703344064467\n" + -"20061112,3.83944153578,0.802703592906,4.05405405405,0.81058250986\n" + -"20061113,2.47787610619,0.653984033555,2.20338983051,0.604340313133\n" + -"20061114,1.77304964539,0.55569466381,2.22222222222,0.60944692682\n" + -"20061115,2.30088495575,0.630766388737,0.843170320405,0.375484163785\n" + -"20061116,1.57894736842,0.522144132232,2.19594594595,0.602321544724\n" + -"20061118,2.45183887916,0.647198426991,1.69491525424,0.531417655826\n" + -"20061119,3.52733686067,0.774700921683,1.85185185185,0.55316023504\n" + -"20061120,2.97723292469,0.711254751484,2.6981450253,0.665374048085\n" + -"20061121,2.29681978799,0.629665059963,2.01680672269,0.576301104352\n" + -"20061122,3.01418439716,0.719945245328,2.5466893039,0.649125445325\n" + -"20061123,3.78378378378,0.809917534069,2.6936026936,0.664269394219\n" + -"20061124,3.18584070796,0.738851643987,2.01005025126,0.57439025002\n" + -"20061125,2.83185840708,0.697868332879,3.066439523,0.711598843969\n" + -"20061126,3.01953818828,0.7212041046,2.53378378378,0.645878720149\n" + -"20061127,2.81195079086,0.693033387099,1.51006711409,0.499540743312\n" + -"20061128,2.97723292469,0.711254751484,2.54237288136,0.648039583782\n" + -"20061129,1.41093474427,0.495309102312,3.02013422819,0.701020603129"; -} diff --git a/gadget.xml b/gadget.xml deleted file mode 100644 index 07a1aba..0000000 --- a/gadget.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - ]]> -
-
diff --git a/generate-combined.sh b/generate-combined.sh deleted file mode 100755 index 26d4a42..0000000 --- a/generate-combined.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -# Generates a single JS file that's easier to include. - -GetSources () { - # Include dyraph-options-reference only if DEBUG environment variable is set. - if [ ! -z "$DEBUG" ]; then - maybe_options_reference=dygraph-options-reference.js - else - maybe_options_reference='' - fi - - # This list needs to be kept in sync w/ the one in dygraph-dev.js - # and the one in jsTestDriver.conf. Order matters, except for the plugins. - for F in \ - polyfills/console.js \ - dashed-canvas.js \ - dygraph-options.js \ - dygraph-layout.js \ - dygraph-canvas.js \ - dygraph.js \ - dygraph-utils.js \ - dygraph-gviz.js \ - dygraph-interaction-model.js \ - dygraph-tickers.js \ - dygraph-plugin-base.js \ - plugins/*.js \ - dygraph-plugin-install.js \ - $maybe_options_reference \ - datahandler/datahandler.js \ - datahandler/default.js \ - datahandler/default-fractions.js \ - datahandler/bars.js \ - datahandler/bars-custom.js \ - datahandler/bars-error.js \ - datahandler/bars-fractions.js - do - echo "$F" - done -} - -# Pack all the JS together. -CatSources () { - GetSources \ - | xargs cat -} - -Copyright () { - echo '/*! @license Copyright 2014 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */' -} - -CatCompressed () { - node_modules/uglify-js/bin/uglifyjs \ - $(GetSources | xargs) \ - --compress warnings=false \ - --mangle \ - --define DEBUG=false \ - --preamble "$(Copyright)" \ - $* -} - -ACTION="${1:-update}" -case "$ACTION" in -ls) - GetSources - ;; -cat) - Copyright - CatSources - ;; -cat-dev) - DEBUG=true - Copyright - CatSources - ;; -compress*|cat_compress*) - CatCompressed - ;; -update) - CatCompressed --source-map dygraph-combined.js.map \ - > dygraph-combined.js - chmod a+r dygraph-combined.js dygraph-combined.js.map - ;; -*) - echo >&2 "Unknown action '$ACTION'" - exit 1 - ;; -esac diff --git a/generate-jar.sh b/generate-jar.sh deleted file mode 100755 index 2c1d12d..0000000 --- a/generate-jar.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -# Generates a JAR file that can be used from GWT to load Dygraphs - -jar -cf dygraph-gwt.jar -C gwt org diff --git a/jsTestDriver.conf b/jsTestDriver.conf deleted file mode 100644 index ec581b3..0000000 --- a/jsTestDriver.conf +++ /dev/null @@ -1,34 +0,0 @@ -server: http://localhost:9876 - -# This list needs to be kept in sync w/ the one in dygraph-dev.js -# and the one in generate-combined.sh. -load: - - dashed-canvas.js - - dygraph-layout.js - - dygraph-canvas.js - - dygraph-options.js - - dygraph.js - - dygraph-utils.js - - dygraph-gviz.js - - dygraph-interaction-model.js - - dygraph-options-reference.js - - dygraph-tickers.js - - dygraph-dev.js - - dygraph-plugin-base.js - - plugins/*.js - - dygraph-plugin-install.js - - datahandler/datahandler.js - - datahandler/default.js - - datahandler/default-fractions.js - - datahandler/bars.js - - datahandler/bars-error.js - - datahandler/bars-custom.js - - datahandler/bars-fractions.js - - extras/smooth-plotter.js - - auto_tests/tests/*.js - - auto_tests/lib/jquery-1.4.2.js - -plugin: - - name: "coverage" - jar: "auto_tests/lib/coverage-1.3.5.jar" - module: "com.google.jstestdriver.coverage.CoverageModule" diff --git a/phantom-driver.js b/phantom-driver.js deleted file mode 100644 index c534964..0000000 --- a/phantom-driver.js +++ /dev/null @@ -1,203 +0,0 @@ -// Invoke via: ./test.sh -// -// or phantomjs phantom-driver.js [testCase.test] -// -// For more on phantomjs, visit www.phantomjs.org. - -var RunAllAutoTests = function(done_callback) { - -var page = require('webpage').create(); - -// NOTE: Cannot include '#' or '?' in this URL. -var url = 'auto_tests/misc/local.html'; - -// NOTE: changing the line below to this: -// page.open(url, function(status)) { -// makes phantomjs hang. -page.open(url, function(status) { - if (status !== 'success') { - console.warn('Page status: ' + status); - console.log(page); - phantom.exit(); - } - - var testCase, test; - var verbose = false; - var optIdx = 0; - if (phantom.args.length > 0 && phantom.args[0] === "--verbose") { - verbose = true; - optIdx = 1; - } - if (phantom.args.length == optIdx + 1) { - var parts = phantom.args[optIdx].split('.'); - if (2 != parts.length) { - console.warn('Usage: phantomjs phantom-driver.js [--verbose] [testCase.test]'); - phantom.exit(); - } - testCase = parts[0]; - test = parts[1]; - } - - var loggingOn = false; - - page.onConsoleMessage = function (msg) { - if (msg == 'Running ' + test) { - loggingOn = true; - } else if (msg.substr(0, 'Running'.length) == 'Running') { - loggingOn = false; - } - if (verbose || loggingOn) console.log(msg); - }; - - page.onError = function (msg, trace) { - console.log(msg); - trace.forEach(function(item) { - console.log(' ', item.file, ':', item.line); - }) - }; - - var results; - - // Run all tests. - var start = new Date().getTime(); - results = page.evaluate(function() { - var num_passing = 0, num_failing = 0; - var failures = []; - - jstestdriver.attachListener({ - finish : function(tc, name, result, e) { - console.log("Result:", tc.name, name, result, e); - if (result) { - // console.log(testCase + '.' + test + ' passed'); - num_passing++; - } else { - num_failing++; - failures.push(tc.name + '.' + name); - } - } - }); - var testCases = getAllTestCases(); - for (var idx in testCases) { - var entry = testCases[idx]; - - var prototype = entry.testCase; - var tc = new entry.testCase(); - var result = tc.runAllTests(); - } - return { - num_passing : num_passing, - num_failing : num_failing, - failures : failures - }; - }); - var end = new Date().getTime(); - var elapsed = (end - start) / 1000; - - console.log('Ran ' + (results.num_passing + results.num_failing) + ' tests in ' + elapsed + 's.'); - console.log(results.num_passing + ' test(s) passed'); - console.log(results.num_failing + ' test(s) failed:'); - for (var i = 0; i < results.failures.length; i++) { - // TODO(danvk): print an auto_test/misc/local URL that runs this test. - console.log(' ' + results.failures[i] + ' failed.'); - } - - done_callback(results.num_failing, results.num_passing); -}); - -}; - -// Load all "tests/" pages. -var LoadAllManualTests = function(totally_done_callback) { - -var fs = require('fs'); -var tests = fs.list('tests'); -var pages = []; - -function make_barrier_closure(n, fn) { - var calls = 0; - return function() { - calls++; - if (calls == n) { - fn(); - } else { - // console.log('' + calls + ' done, ' + (n - calls) + ' remain'); - } - }; -} - -var tasks = []; -for (var i = 0; i < tests.length; i++) { - if (tests[i].substr(-5) != '.html') continue; - tasks.push(tests[i]); -} -tasks = [ 'independent-series.html' ]; - -var loaded_page = make_barrier_closure(tasks.length, function() { - // Wait 2 secs to allow JS errors to happen after page load. - setTimeout(function() { - var success = 0, failures = 0; - for (var i = 0; i < pages.length; i++) { - if (pages[i].success && !pages[i].hasErrors) { - success++; - } else { - failures++; - } - } - console.log('Successfully loaded ' + success + ' / ' + - (success + failures) + ' test pages.'); - totally_done_callback(failures, success); - }, 2000); -}); - - -for (var i = 0; i < tasks.length; i++) { - var url = 'file://' + fs.absolute('tests/' + tasks[i]); - pages.push(function(path, url) { - var page = require('webpage').create(); - page.success = false; - page.hasErrors = false; - page.onError = function (msg, trace) { - console.log(path + ': ' + msg); - page.hasErrors = true; - trace.forEach(function(item) { - console.log(' ', item.file, ':', item.line); - }); - }; - page.onLoadFinished = function(status) { - if (status == 'success') { - page.success = true; - } - if (!page.done) loaded_page(); - page.done = true; - }; - page.open(url); - return page; - }(tasks[i], url)); -} - -}; - - -// First run all auto_tests. -// If they all pass, load the manual tests. -RunAllAutoTests(function(num_failing, num_passing) { - if (num_failing !== 0) { - console.log('FAIL'); - phantom.exit(); - } else { - console.log('PASS'); - } - phantom.exit(); - - // This is not yet reliable enough to be useful: - /* - LoadAllManualTests(function(failing, passing) { - if (failing !== 0) { - console.log('FAIL'); - } else { - console.log('PASS'); - } - phantom.exit(); - }); - */ -}); diff --git a/phantom-perf.js b/phantom-perf.js deleted file mode 100644 index b98c3f0..0000000 --- a/phantom-perf.js +++ /dev/null @@ -1,94 +0,0 @@ -// dygraphs command-line performance benchmark. -// -// Invoke as: -// -// phantomjs phantom-perf.js 1000 100 5 -// -// If the test succeeds, it will print out something like: -// -// 1000/100/5: 1309.4+/-43.4 ms (1284, 1245, 1336, 1346, 1336) -// -// This is mean +/- standard deviation, followed by a list of the individual -// times for each repetition, in milliseconds. - -var system = require('system'), - fs = require('fs'); - -var tmpfile = "tmp-dygraph-test-params.js"; -var url = 'tests/dygraph-many-points-benchmark.html'; - -function fail(msg){ - console.warn(msg); - phantom.exit(1); -} - -function assert(condition, msg){ - if (condition) return; - fail(msg); -} - -var config_file_template = - "document.getElementById('points').value = (points);\n" + - "document.getElementById('series').value = (series);\n" + - "document.getElementById('repetitions').value = (repetitions);\n"; - -var RunBenchmark = function(points, series, repetitions, done_callback) { - var page = require('webpage').create(); - - // page.evalute() is seriously locked down. - // This was the only way I could find to pass the parameters to the page. - fs.write(tmpfile, - config_file_template - .replace("(points)", points) - .replace("(series)", series) - .replace("(repetitions)", repetitions), - "w"); - - page.open(url, function(status) { - if (status !== 'success') { - console.warn('Page status: ' + status); - console.log(page); - phantom.exit(); - } - - assert(page.injectJs(tmpfile), "Unable to inject JS."); - fs.remove(tmpfile); - - var start = new Date().getTime(); - var rep_times = page.evaluate(function() { - var rep_times = updatePlot(); - return rep_times; - }); - var end = new Date().getTime(); - var elapsed = (end - start) / 1000; - done_callback(rep_times); - }); -}; - - -var points, series, repetitions; -if (4 != system.args.length) { - console.warn('Usage: phantomjs phantom-driver.js (points) (series) (repititions)'); - phantom.exit(); -} - -points = parseInt(system.args[1]); -series = parseInt(system.args[2]); -repetitions = parseInt(system.args[3]); -assert(points != null, "Couldn't parse " + system.args[1]); -assert(series != null, "Couldn't parse " + system.args[2]); -assert(repetitions != null, "Couldn't parse " + system.args[3]); - - -RunBenchmark(points, series, repetitions, function(rep_times) { - var mean = 0.0, std = 0.0; - rep_times.forEach(function(x) { mean += x; } ); - mean /= rep_times.length; - rep_times.forEach(function(x) { std += Math.pow(x - mean, 2); }); - std = Math.sqrt(std / (rep_times.length - 1)); - - console.log(points + '/' + series + '/' + repetitions + ': ' + - mean.toFixed(1) + '+/-' + std.toFixed(1) + ' ms (' + - rep_times.join(', ') + ')'); - phantom.exit(); -}); -- 2.7.4