Compare commits
No commits in common. "benchmark" and "main" have entirely different histories.
@ -1,43 +0,0 @@
|
||||
import Benchmark from 'benchmark'
|
||||
import padRight from 'pad-right'
|
||||
import math from '../src/pocomath.mjs'
|
||||
|
||||
function pad (text) {
|
||||
return padRight(text, 40, ' ')
|
||||
}
|
||||
|
||||
const maxCoeff = 5
|
||||
function countRoots () {
|
||||
let polys = 0
|
||||
let roots = 0
|
||||
for (let d = 0; d <= maxCoeff; ++d) {
|
||||
for (let c = 0; c <= maxCoeff; ++c) {
|
||||
for (let b = 0; b <= maxCoeff; ++b) {
|
||||
for (let a = 1; a <= maxCoeff; ++a) {
|
||||
polys += 1
|
||||
roots += math.length(math.polynomialRoot(d, c, b, a))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [polys, roots]
|
||||
}
|
||||
|
||||
const test = countRoots()
|
||||
console.log('There are', test[1], 'roots of the', test[0], 'integer cubic')
|
||||
console.log('polynomials (with coefficients <=', maxCoeff, ')')
|
||||
|
||||
const results = []
|
||||
|
||||
const suite = new Benchmark.Suite()
|
||||
suite
|
||||
.add(pad('count roots'), function () {
|
||||
const res = countRoots()
|
||||
results.push(res)
|
||||
})
|
||||
.on('cycle', function (event) {
|
||||
console.log(String(event.target))
|
||||
})
|
||||
.on('complete', function () {
|
||||
})
|
||||
.run()
|
@ -20,9 +20,7 @@
|
||||
license: 'Apache-2.0',
|
||||
type: 'module',
|
||||
devDependencies: {
|
||||
benchmark: '^2.1.4',
|
||||
mocha: '^10.0.0',
|
||||
'pad-right': '^0.2.2',
|
||||
},
|
||||
dependencies: {
|
||||
'bigint-isqrt': '^0.2.1',
|
||||
|
@ -1,11 +1,9 @@
|
||||
lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
benchmark: ^2.1.4
|
||||
bigint-isqrt: ^0.2.1
|
||||
fraction.js: ^4.2.0
|
||||
mocha: ^10.0.0
|
||||
pad-right: ^0.2.2
|
||||
typed-function: ^3.0.0
|
||||
|
||||
dependencies:
|
||||
@ -14,9 +12,7 @@ dependencies:
|
||||
typed-function: 3.0.0
|
||||
|
||||
devDependencies:
|
||||
benchmark: 2.1.4
|
||||
mocha: 10.0.0
|
||||
pad-right: 0.2.2
|
||||
|
||||
packages:
|
||||
|
||||
@ -57,13 +53,6 @@ packages:
|
||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||
dev: true
|
||||
|
||||
/benchmark/2.1.4:
|
||||
resolution: {integrity: sha512-l9MlfN4M1K/H2fbhfMy3B7vJd6AGKJVQn2h6Sg/Yx+KckoUA7ewS5Vv6TjSq18ooE1kS9hhAlQRH3AkXIh/aOQ==}
|
||||
dependencies:
|
||||
lodash: 4.17.21
|
||||
platform: 1.3.6
|
||||
dev: true
|
||||
|
||||
/bigint-isqrt/0.2.1:
|
||||
resolution: {integrity: sha512-x43s2Qx5l5ShFZFA5xejJfPtV1vXISyWUXlrZeJTx9F6D2ex3BR6AwWnIz4ITAu5nTy3hp+d+ClGu7qUGcgY8g==}
|
||||
dev: false
|
||||
@ -318,10 +307,6 @@ packages:
|
||||
p-locate: 5.0.0
|
||||
dev: true
|
||||
|
||||
/lodash/4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
dev: true
|
||||
|
||||
/log-symbols/4.1.0:
|
||||
resolution: {integrity: sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==}
|
||||
engines: {node: '>=10'}
|
||||
@ -411,13 +396,6 @@ packages:
|
||||
p-limit: 3.1.0
|
||||
dev: true
|
||||
|
||||
/pad-right/0.2.2:
|
||||
resolution: {integrity: sha512-4cy8M95ioIGolCoMmm2cMntGR1lPLEbOMzOKu8bzjuJP6JpzEMQcDHmh7hHLYGgob+nKe1YHFMaG4V59HQa89g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dependencies:
|
||||
repeat-string: 1.6.1
|
||||
dev: true
|
||||
|
||||
/path-exists/4.0.0:
|
||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||
engines: {node: '>=8'}
|
||||
@ -433,10 +411,6 @@ packages:
|
||||
engines: {node: '>=8.6'}
|
||||
dev: true
|
||||
|
||||
/platform/1.3.6:
|
||||
resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}
|
||||
dev: true
|
||||
|
||||
/randombytes/2.1.0:
|
||||
resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==}
|
||||
dependencies:
|
||||
@ -450,11 +424,6 @@ packages:
|
||||
picomatch: 2.3.1
|
||||
dev: true
|
||||
|
||||
/repeat-string/1.6.1:
|
||||
resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
|
||||
engines: {node: '>=0.10'}
|
||||
dev: true
|
||||
|
||||
/require-directory/2.1.1:
|
||||
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
Loading…
Reference in New Issue
Block a user