RunAsync

JavaScript performance comparison

Test case created

Info

Test implementation using RunAsync and using synchronous code execution

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://raw.github.com/ricmrodrigues/runasync/master/dist/runasync.min.js"></script>

<button id="clickme">Click me!</button>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
using RunAsync
// async test
            var task = Task.run(function() {                                
                //dispath something to UI thread
                var millisecondsToWait = 500;
                setTimeout(function() {
                    dispatch(function() {
                        $("body").append("<button>yay....</button>");
                    });
                }, millisecondsToWait);                                
               
                return millisecondsToWait;
            });
           
            //execute something after the background task, in the UI thread
            task.when(function(value) {
                $('#clickme').text("#"+value+" done!");
                console.log("my async code #"+value+" completed!!");
                console.log("output: " + value);
            });
           
            //after the previous task ends, spin up a new task
            //with its result as argument
            task.continueWith(function(value) {
                return value;
            }).when(function(value) {
                console.log("result from task " + value);
                deferred.resolve();
            });  
pending…
using synchronous code
                     
                //dispath something to UI thread
                var millisecondsToWait = 500;
                setTimeout(function() {
                    dispatch(function() {
                        $("body").append("<button>yay....</button>");
                    });
                }, millisecondsToWait);                                
           

var idx = 10,
    value = 40;
                $('#clickme').text("#"+idx+" done!");
                console.log("my async code #"+idx+" completed!!");
                console.log("output: " + value);
           
            //after the previous task ends, spin up a new task
            //with its result as argument
            var bla = (function(value) {
                return value;
            })(20);

             var blu = (function(value) {
                console.log("result from task " + value);
            })(50);  
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

Add a comment