Reactive libraries comparison

JavaScript performance comparison

Test case created by nin-jin

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.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
$jin.atom
AtomModel.subSet()

for( var i = 0; i < countOfModels; ++i ){
	AtomModel.evenOrNot( i % 10 > 4 )
	var model = AtomModel.all()[ i ]
	model.id( model.id() + 1 )
}

AtomModel.subSet()
pending…
KnockOut
KOModel.subSet()

for( var i = 0; i < countOfModels; ++i ){
	KOModel.evenOrNot( i % 10 > 4 )
	var model = KOModel.all()[ i ]
	model.id( model.id() + 1 )
}

KOModel.subSet()
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 Comments