Reactive libraries comparison
JavaScript performance comparison
Preparation code
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script>
<script src="http://nin-jin.github.io/atom/index.env=web.stage=release.js"></script>
<script>
countOfModels = 200
AtomModel = function( id ){
this.id( id )
}
$jin.atom.prop({ 'AtomModel..id': {} })
$jin.atom.prop.list({ 'AtomModel.all': {
pull: function(){
return Array( countOfModels )
.join( ',' )
.split( ',' )
.map( function( str, index ){
return new AtomModel( index )
}.bind( this ) )
}
}})
$jin.atom.prop.list({ 'AtomModel.evenOrNot': {} })
$jin.atom.prop.list({ 'AtomModel.subSet': {
pull: function(){
return this.all()
.filter( function( model ){
return this.evenOrNot() ? ( model.id() % 2 ) : !( model.id() % 2 )
}.bind( this ) )
}
}})
KOModel = function( id ){
this.id = ko.observable( id )
}
KOModel.all = ko.computed( function( ){
return Array( countOfModels )
.join( ',' )
.split( ',' )
.map( function( str, index ){
return new KOModel( index )
}.bind( this ) )
}, KOModel )
KOModel.evenOrNot = ko.observable()
KOModel.subSet = ko.computed( function( ){
return this.all()
.filter( function( model ){
return this.evenOrNot() ? ( model.id() % 2 ) : !( model.id() % 2 )
}.bind( this ) )
}, KOModel )
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
$jin.atom
|
|
pending… |
KnockOut
|
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit
to the URL.
0 Comments