Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
aggiunto esempio imperativo ed eempio benchmark
Browse files Browse the repository at this point in the history
aggiunto comando yarn bench per compilare e lanciare i benchmark
  • Loading branch information
korsmakolnikov committed Sep 28, 2017
1 parent ec612f8 commit f019ddc
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ php/bin/
php/vendor/
js/node_modules
js/.idea
js/lib/
.DS_Store
js/coverage
js/build
Expand Down
3 changes: 3 additions & 0 deletions js/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
9 changes: 8 additions & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
"scripts": {
"start": "react-scripts start",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"bench-build": "babel src -d lib",
"bench-run": "node lib/Benchmarks.js",
"bench": "yarn bench-build && yarn bench-run"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"benchmark": "^2.1.4",
"deep-freeze": "^0.0.1",
"expect": "^21.0.0"
}
Expand Down
8 changes: 8 additions & 0 deletions js/src/AppImp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const ZeroA = () => {
let out = [];
for (let i = 1; i <= 3; i++) {
out.push(i);
}

return out;
};
10 changes: 10 additions & 0 deletions js/src/AppImp.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import expect from 'expect';
import * as kata from './AppImp';

export const UOMINI = ["Tizio", "Caio", "Sempronio", "Mevio", "Filano", "Calpurnio"];
export const DONNE = ["Anna", "Carla", "Angela", "Chiara", "Emma", "Maria", "Sara"];


it('kata.ZeroA restituisce [1,2,3]', () => {
expect(kata.ZeroA()).toEqual([1, 2, 3]);
});
24 changes: 24 additions & 0 deletions js/src/Benchmarks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Benchmark from 'benchmark';
let suite = new Benchmark.Suite();

import * as kataFP from './App';
import * as kataImp from './AppImp';


suite.add('KataZeroA functional Benchmark', function () {
kataFP.ZeroA();
})
.add('KataZeroA imperative Benchmark', function () {
kataImp.ZeroA();
})


.on('cycle', function (event) {
console.log(String(event.target));
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})


.run({'async': true});
165 changes: 133 additions & 32 deletions js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,27 @@ axobject-query@^0.1.0:
dependencies:
ast-types-flow "0.0.7"

babel-cli@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1"
dependencies:
babel-core "^6.26.0"
babel-polyfill "^6.26.0"
babel-register "^6.26.0"
babel-runtime "^6.26.0"
commander "^2.11.0"
convert-source-map "^1.5.0"
fs-readdir-recursive "^1.0.0"
glob "^7.1.2"
lodash "^4.17.4"
output-file-sync "^1.1.2"
path-is-absolute "^1.0.1"
slash "^1.0.0"
source-map "^0.5.6"
v8flags "^2.1.1"
optionalDependencies:
chokidar "^1.6.1"

[email protected]:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
Expand Down Expand Up @@ -863,6 +884,14 @@ babel-plugin-transform-strict-mode@^6.24.1:
babel-runtime "^6.22.0"
babel-types "^6.24.1"

babel-polyfill@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
dependencies:
babel-runtime "^6.26.0"
core-js "^2.5.0"
regenerator-runtime "^0.10.5"

[email protected]:
version "1.5.2"
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.5.2.tgz#cd4ae90a6e94b709f97374b33e5f8b983556adef"
Expand Down Expand Up @@ -898,6 +927,41 @@ [email protected]:
invariant "^2.2.2"
semver "^5.3.0"

babel-preset-env@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.6.0.tgz#2de1c782a780a0a5d605d199c957596da43c44e4"
dependencies:
babel-plugin-check-es2015-constants "^6.22.0"
babel-plugin-syntax-trailing-function-commas "^6.22.0"
babel-plugin-transform-async-to-generator "^6.22.0"
babel-plugin-transform-es2015-arrow-functions "^6.22.0"
babel-plugin-transform-es2015-block-scoped-functions "^6.22.0"
babel-plugin-transform-es2015-block-scoping "^6.23.0"
babel-plugin-transform-es2015-classes "^6.23.0"
babel-plugin-transform-es2015-computed-properties "^6.22.0"
babel-plugin-transform-es2015-destructuring "^6.23.0"
babel-plugin-transform-es2015-duplicate-keys "^6.22.0"
babel-plugin-transform-es2015-for-of "^6.23.0"
babel-plugin-transform-es2015-function-name "^6.22.0"
babel-plugin-transform-es2015-literals "^6.22.0"
babel-plugin-transform-es2015-modules-amd "^6.22.0"
babel-plugin-transform-es2015-modules-commonjs "^6.23.0"
babel-plugin-transform-es2015-modules-systemjs "^6.23.0"
babel-plugin-transform-es2015-modules-umd "^6.23.0"
babel-plugin-transform-es2015-object-super "^6.22.0"
babel-plugin-transform-es2015-parameters "^6.23.0"
babel-plugin-transform-es2015-shorthand-properties "^6.22.0"
babel-plugin-transform-es2015-spread "^6.22.0"
babel-plugin-transform-es2015-sticky-regex "^6.22.0"
babel-plugin-transform-es2015-template-literals "^6.22.0"
babel-plugin-transform-es2015-typeof-symbol "^6.23.0"
babel-plugin-transform-es2015-unicode-regex "^6.22.0"
babel-plugin-transform-exponentiation-operator "^6.22.0"
babel-plugin-transform-regenerator "^6.22.0"
browserslist "^2.1.2"
invariant "^2.2.2"
semver "^5.3.0"

babel-preset-flow@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-preset-flow/-/babel-preset-flow-6.23.0.tgz#e71218887085ae9a24b5be4169affb599816c49d"
Expand Down Expand Up @@ -1016,6 +1080,13 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

benchmark@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/benchmark/-/benchmark-2.1.4.tgz#09f3de31c916425d498cc2ee565a0ebf3c2a5629"
dependencies:
lodash "^4.17.4"
platform "^1.3.3"

big.js@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978"
Expand Down Expand Up @@ -1302,7 +1373,7 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

chokidar@^1.6.0, chokidar@^1.7.0:
chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
dependencies:
Expand Down Expand Up @@ -1434,7 +1505,7 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"

[email protected], commander@~2.11.0:
[email protected], commander@^2.11.0, commander@~2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"

Expand Down Expand Up @@ -2370,15 +2441,15 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
homedir-polyfill "^1.0.1"

expect@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/expect/-/expect-21.0.0.tgz#55fbb07e989479863663975ae8e9ec51753c99ca"
version "21.2.1"
resolved "https://registry.yarnpkg.com/expect/-/expect-21.2.1.tgz#003ac2ac7005c3c29e73b38a272d4afadd6d1d7b"
dependencies:
ansi-styles "^3.2.0"
jest-diff "^21.0.0"
jest-get-type "^21.0.0"
jest-matcher-utils "^21.0.0"
jest-message-util "^21.0.0"
jest-regex-util "^21.0.0"
jest-diff "^21.2.1"
jest-get-type "^21.2.0"
jest-matcher-utils "^21.2.1"
jest-message-util "^21.2.1"
jest-regex-util "^21.2.0"

express@^4.13.3:
version "4.15.4"
Expand Down Expand Up @@ -2646,6 +2717,10 @@ fs-extra@^0.30.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"

fs-readdir-recursive@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -2800,7 +2875,7 @@ got@^5.0.0:
unzip-response "^1.0.2"
url-parse-lax "^1.0.0"

graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

Expand Down Expand Up @@ -3508,14 +3583,14 @@ jest-diff@^20.0.3:
jest-matcher-utils "^20.0.3"
pretty-format "^20.0.3"

jest-diff@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-21.0.0.tgz#b996ba2963a783125e6bc59fd5623bce67df7f17"
jest-diff@^21.2.1:
version "21.2.1"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-21.2.1.tgz#46cccb6cab2d02ce98bc314011764bb95b065b4f"
dependencies:
chalk "^2.0.1"
diff "^3.2.0"
jest-get-type "^21.0.0"
pretty-format "^21.0.0"
jest-get-type "^21.2.0"
pretty-format "^21.2.1"

jest-docblock@^20.0.3:
version "20.0.3"
Expand All @@ -3536,9 +3611,9 @@ jest-environment-node@^20.0.3:
jest-mock "^20.0.3"
jest-util "^20.0.3"

jest-get-type@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-21.0.0.tgz#ed8667533c0a24a4feebbf492661f23abac3620b"
jest-get-type@^21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-21.2.0.tgz#f6376ab9db4b60d81e39f30749c6c466f40d4a23"

jest-haste-map@^20.0.4:
version "20.0.5"
Expand Down Expand Up @@ -3572,13 +3647,13 @@ jest-matcher-utils@^20.0.3:
chalk "^1.1.3"
pretty-format "^20.0.3"

jest-matcher-utils@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-21.0.0.tgz#493dc25b9ed6a23a61802ca20656f0f1c16f15b1"
jest-matcher-utils@^21.2.1:
version "21.2.1"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-21.2.1.tgz#72c826eaba41a093ac2b4565f865eb8475de0f64"
dependencies:
chalk "^2.0.1"
jest-get-type "^21.0.0"
pretty-format "^21.0.0"
jest-get-type "^21.2.0"
pretty-format "^21.2.1"

jest-matchers@^20.0.3:
version "20.0.3"
Expand All @@ -3597,9 +3672,9 @@ jest-message-util@^20.0.3:
micromatch "^2.3.11"
slash "^1.0.0"

jest-message-util@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-21.0.0.tgz#cd49c2e91d7a227e622884c418185a1a7cbe1fd6"
jest-message-util@^21.2.1:
version "21.2.1"
resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-21.2.1.tgz#bfe5d4692c84c827d1dcf41823795558f0a1acbe"
dependencies:
chalk "^2.0.1"
micromatch "^2.3.11"
Expand All @@ -3613,9 +3688,9 @@ jest-regex-util@^20.0.3:
version "20.0.3"
resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-20.0.3.tgz#85bbab5d133e44625b19faf8c6aa5122d085d762"

jest-regex-util@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-21.0.0.tgz#f13c382a1c55515c20471390ab38e5d71cbd320e"
jest-regex-util@^21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-21.2.0.tgz#1b1e33e63143babc3e0f2e6c9b5ba1eb34b2d530"

jest-resolve-dependencies@^20.0.3:
version "20.0.3"
Expand Down Expand Up @@ -4454,6 +4529,14 @@ osenv@^0.1.0, osenv@^0.1.4:
os-homedir "^1.0.0"
os-tmpdir "^1.0.0"

output-file-sync@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76"
dependencies:
graceful-fs "^4.1.4"
mkdirp "^0.5.1"
object-assign "^4.1.0"

p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
Expand Down Expand Up @@ -4626,6 +4709,10 @@ pkg-dir@^2.0.0:
dependencies:
find-up "^2.1.0"

platform@^1.3.3:
version "1.3.4"
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.4.tgz#6f0fb17edaaa48f21442b3a975c063130f1c3ebd"

pluralize@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762"
Expand Down Expand Up @@ -4952,9 +5039,9 @@ pretty-format@^20.0.3:
ansi-regex "^2.1.1"
ansi-styles "^3.0.0"

pretty-format@^21.0.0:
version "21.0.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.0.0.tgz#bea1522c4c47e49b44db5b6fbf83e7737251f305"
pretty-format@^21.2.1:
version "21.2.1"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.2.1.tgz#ae5407f3cf21066cd011aa1ba5fce7b6a2eddb36"
dependencies:
ansi-regex "^3.0.0"
ansi-styles "^3.2.0"
Expand Down Expand Up @@ -5283,6 +5370,10 @@ regenerate@^1.2.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260"

regenerator-runtime@^0.10.5:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"

regenerator-runtime@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.0.tgz#7e54fe5b5ccd5d6624ea6255c3473be090b802e1"
Expand Down Expand Up @@ -6199,6 +6290,10 @@ url@^0.11.0:
punycode "1.3.2"
querystring "0.2.0"

user-home@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190"

util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down Expand Up @@ -6229,6 +6324,12 @@ uuid@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"

v8flags@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4"
dependencies:
user-home "^1.1.1"

validate-npm-package-license@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"
Expand Down

0 comments on commit f019ddc

Please sign in to comment.