Skip to content

Commit

Permalink
fix perf, including most.js.
Browse files Browse the repository at this point in the history
  • Loading branch information
StreetStrider committed Dec 9, 2021
1 parent 0608377 commit f027825
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
7 changes: 4 additions & 3 deletions perf/fluh.perf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import Bud from '../lib/Bud'
import Noop from '../lib/Noop'
import Bud from '../lib/Bud'
import Nothing from '../lib/Nothing'
import Many from '../lib/Many'

import join from '../lib/join'
Expand Down Expand Up @@ -114,7 +114,7 @@ export default
{
if (n === 10)
{
b = join(b, Noop)
b = join(b, b => ((b % 2) && (b + 1) || Nothing))
}
else
{
Expand All @@ -126,6 +126,7 @@ export default

return () =>
{
a.emit(18)
a.emit(17)
}
},
Expand Down
3 changes: 2 additions & 1 deletion perf/flyd.perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default
{
if (n === 10)
{
b = filter(() => false, b)
b = filter(b => Boolean(b % 2), b)
}
else
{
Expand All @@ -106,6 +106,7 @@ export default

return () =>
{
a(18)
a(17)
}
},
Expand Down
24 changes: 14 additions & 10 deletions perf/most.perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ export default

var c = merge(a, b)

var run = tap(() => { n = (n + 1); (h1.rs || h2.rs)() }, c)
var run = tap(x => { n = (n + 1); if (x % 2) h1.rs(); else h2.rs() }, c)
runEffects(run, newDefaultScheduler())

return () =>
return async () =>
{
return h1.next(2), h2.next(17)
await h1.next(17)
await h2.next(18)
}
},

Expand Down Expand Up @@ -124,27 +125,30 @@ export default
var n = 1

var handle = Handle()
var a = handle.source

var b = a
var b = handle.source
for (var N = 0; N < 100; N++)
{
if (N === 10)
{
b = filter(() => false, b)
var run1 = tap(b => ((b % 2) || handle.rs()), b)
b = filter(b => Boolean(b % 2), b)
}
else
{
b = map(b => b + 1, b)
}
}

var run = tap(() => { n = (n + 1); handle.rs() }, b)
runEffects(run, newDefaultScheduler())
var run2 = tap(() => { n = (n + 1); handle.rs() }, b)

return () =>
runEffects(run1, newDefaultScheduler())
runEffects(run2, newDefaultScheduler())

return async () =>
{
return handle.next(17)
await handle.next(18)
await handle.next(17)
}
},
}
36 changes: 22 additions & 14 deletions perf/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import { cycle, complete } from 'benny'
import fluh from './fluh.perf'
import flyd from './flyd.perf'
// import rxjs from './rxjs.perf'
// import most from './most.perf'
import most from './most.perf'


xSuite()

Suite('zero',
async function benchmark ()
{

await Suite('zero',
[
add('zero', () =>
{
Expand All @@ -24,52 +27,54 @@ Suite('zero',
}),
])

xSuite('special',
await xSuite('special',
[
add('deep linear', fluh.deep_linear),
add('deep linear many', fluh.deep_linear_many)
add('deep linear many', fluh.deep_linear_many),
])

Suite('diamond',
await Suite('diamond',
[
add('diamond (FLUH)', fluh.diamond),
add('diamond (flyd)', flyd.diamond),
// add('diamond (rxjs)', rxjs.diamond),
// add('diamond (most)', most.diamond),
add('diamond (most)', most.diamond),
])

Suite('merge',
await Suite('merge',
[
add('merge (FLUH)', fluh.merge),
add('merge (flyd)', flyd.merge),
// add('merge (rxjs)', rxjs.merge),
// add('merge (most)', most.merge),
add('merge (most)', most.merge),
])

Suite('deep_linear',
await Suite('deep_linear',
[
add('deep linear (FLUH)', fluh.deep_linear),
add('deep linear (flyd)', flyd.deep_linear),
// add('deep linear (rxjs)', rxjs.deep_linear),
// add('deep linear (most)', most.deep_linear),
add('deep linear (most)', most.deep_linear),
])

Suite('triangle_triangle',
await Suite('triangle_triangle',
[
add('triangle in triangle (FLUH)', fluh.triangle_triangle),
add('triangle in triangle (flyd)', flyd.triangle_triangle),
// add('triangle in triangle (rxjs)', rxjs.triangle_triangle),
// add('triangle in triangle (most)', most.triangle_triangle),
add('triangle in triangle (most)', most.triangle_triangle),
])

Suite('shortcut',
await Suite('shortcut',
[
add('shortcut (FLUH)', fluh.shortcut),
add('shortcut (flyd)', flyd.shortcut),
// add('shortcut (rxjs)', rxjs.shortcut),
// add('shortcut (most)', most.shortcut),
add('shortcut (most)', most.shortcut),
])

}


function xSuite () {}

Expand All @@ -89,3 +94,6 @@ function Suite (name, cases)
}),*/
)
}


benchmark()

0 comments on commit f027825

Please sign in to comment.