Add unit tests for config.json and statistics.js
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Mar 2016 07:15:54 +0000 (07:15 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Mar 2016 07:15:54 +0000 (07:15 +0000)
commit44f18d072de81b5357ed6f32b3318654fac8dbda
tree5253504fb41eb1c395f69e1c75ac7356b2cbecdc
parent8bf14bed4efea814a49d81fe666ba848fef97ddc
Add unit tests for config.json and statistics.js
https://bugs.webkit.org/show_bug.cgi?id=155626

Reviewed by Darin Adler.

Added mocha unit tests for statistics.js and validating config.json. For segmentations, I've extracted
real data from our internal perf dashboard.

Also fixed some bugs covered by these new tests.

* public/shared/statistics.js:
(Statistics.movingAverage): Fixed a bug that forwardWindowSize was never used.
(Statistics.exponentialMovingAverage): Fixed the bug that the moving average starts at 0. It should
start at the first value instead.
(.splitIntoSegmentsUntilGoodEnough): Fixed the bug that we may try to segment a time series into
more parts than there are data points. Clearly, that doesn't make any sense.
(.findOptimalSegmentation): Renamed local variables so that they're more descriptive, and rewrote
the debugging code was the old code was emitting some useless data. Also fixed the bug that the length
of "segmentation" was off by one (we need segmentCount + 1 elements in the array sine we always
include the start of the first segment = 0 and the end of the last segment = values.length).
(.SampleVarianceUpperTriangularMatrix):
(Statistics): Modernized the export code.
* tools/js: Added.
* tools/js/config.js: Added.
(Config): Added.
(Config.prototype.configFilePath): Added.
(Config.prototype.value): Added.
(Config.prototype.path): Added.
* tools/js/database.js: Added.
(Database): Added.
(Database.prototype.connect): Added.
(Database.prototype.disconnect): Added.
* unit-tests: Added.
* unit-tests/checkconfig.js: Added. Validates config.json. This is useful while setting up
a local instance of the perf dashboard.
* unit-tests/statistics-tests.js: Added.
(assert.almostEqual): Added. Asserts that two floating values are within a given significant digits.
(.stdev):
(.delta):
(.computeWelchsT):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198386 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/shared/statistics.js
Websites/perf.webkit.org/tools/js/config.js [new file with mode: 0644]
Websites/perf.webkit.org/tools/js/database.js [new file with mode: 0644]
Websites/perf.webkit.org/unit-tests/checkconfig.js [new file with mode: 0644]
Websites/perf.webkit.org/unit-tests/statistics-tests.js [new file with mode: 0644]