Re: Javascript benchmarks in Google Chrome on Android 4.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Javascript benchmarks in Google Chrome on Android 4.0

Guido Stepken

JavaScript Performance Benchmark (in Samsung Nexus, Google Chrome Beta)

This web page is a simple benchmark for JavaScript analogous to (and directly comparable with) Squeak's tinyBenchmarks. It reports results in terms of operations/sec (simple things like addition and subscripting) and sends/sec (user-defined message to a user-defined object).

n1 = 2; time = 7 milliseconds; 142857143 operations/sec.
n1 = 4; time = 8 milliseconds; 250000000 operations/sec.
n1 = 8; time = 6 milliseconds; 666666667 operations/sec.
n1 = 16; time = 7 milliseconds; 1142857143 operations/sec.
n1 = 32; time = 15 milliseconds; 1066666667 operations/sec.
n1 = 64; time = 27 milliseconds; 1185185185 operations/sec.
n1 = 128; time = 49 milliseconds; 1306122449 operations/sec.
n1 = 256; time = 99 milliseconds; 1292929293 operations/sec.
n1 = 512; time = 197 milliseconds; 1299492386 operations/sec.
n1 = 1024; time = 397 milliseconds; 1289672544 operations/sec.
n1 = 2048; time = 794 milliseconds; 1289672544 operations/sec.

n2 = 24; time = 9 milliseconds; 8336111 sends/sec.
n2 = 25; time = 9 milliseconds; 13488111 sends/sec.
n2 = 26; time = 15 milliseconds; 13094533 sends/sec.
n2 = 27; time = 27 milliseconds; 11770778 sends/sec.
n2 = 28; time = 39 milliseconds; 13185359 sends/sec.
n2 = 29; time = 61 milliseconds; 13640000 sends/sec.
n2 = 30; time = 99 milliseconds; 13598677 sends/sec.
n2 = 31; time = 161 milliseconds; 13529870 sends/sec.
n2 = 32; time = 260 milliseconds; 13556069 sends/sec.
n2 = 33; time = 421 milliseconds; 13546050 sends/sec.
n2 = 34; time = 680 milliseconds; 13569801 sends/sec.

Am 12.02.2012 18:10 schrieb "Jerry Bell" <[hidden email]>:
Hello,

I've been playing around a little with Amber and Javascript.

I found this Javascript benchmark from Dan Ingalls:

http://www.weather-dimensions.com/Dan/JavaScriptBenchmark.html

I copied that code into Amber using the "<  ...   >" syntax for
embedding Javascript code in Amber methods. (Which I discovered in
Number>>jsbenchFib). I made very few changes, only adding extra ">"
escapes in the embedded HTML, and adding a call to the tinyBenchmarks
function at the end.

Here are the results I get from running the Javascript benchmark
directly in my browser:

n1 = 2; time = 1 milliseconds; 1000000000 operations/sec.
n1 = 4; time = 3 milliseconds; 666666667 operations/sec.
n1 = 8; time = 8 milliseconds; 500000000 operations/sec.
n1 = 16; time = 14 milliseconds; 571428571 operations/sec.
n1 = 32; time = 10 milliseconds; 1600000000 operations/sec.
n1 = 64; time = 19 milliseconds; 1684210526 operations/sec.
n1 = 128; time = 40 milliseconds; 1600000000 operations/sec.
n1 = 256; time = 84 milliseconds; 1523809524 operations/sec.
n1 = 512; time = 164 milliseconds; 1560975610 operations/sec.
n1 = 1024; time = 342 milliseconds; 1497076023 operations/sec.
n1 = 2048; time = 690 milliseconds; 1484057971 operations/sec.

n2 = 24; time = 2 milliseconds; 37512500 sends/sec.
n2 = 25; time = 4 milliseconds; 30348250 sends/sec.
n2 = 26; time = 7 milliseconds; 28059714 sends/sec.
n2 = 27; time = 10 milliseconds; 31781100 sends/sec.
n2 = 28; time = 17 milliseconds; 30248765 sends/sec.
n2 = 29; time = 27 milliseconds; 30816296 sends/sec.
n2 = 30; time = 43 milliseconds; 31308581 sends/sec.
n2 = 31; time = 72 milliseconds; 30254292 sends/sec.
n2 = 32; time = 115 milliseconds; 30648504 sends/sec.
n2 = 33; time = 197 milliseconds; 28948665 sends/sec.
n2 = 34; time = 302 milliseconds; 30554520 sends/sec.
n2 = 35; time = 489 milliseconds; 30532417 sends/sec.
n2 = 36; time = 799 milliseconds; 30235065 sends/sec.

Here are the results I get running the benchmark from inside Amber:


n1 = 2; time = 26 milliseconds; 38461538 operations/sec.
n1 = 4; time = 36 milliseconds; 55555556 operations/sec.
n1 = 8; time = 25 milliseconds; 160000000 operations/sec.
n1 = 16; time = 49 milliseconds; 163265306 operations/sec.
n1 = 32; time = 99 milliseconds; 161616162 operations/sec.
n1 = 64; time = 200 milliseconds; 160000000 operations/sec.
n1 = 128; time = 397 milliseconds; 161209068 operations/sec.
n1 = 256; time = 794 milliseconds; 161209068 operations/sec.

n2 = 24; time = 5 milliseconds; 15005000 sends/sec.
n2 = 25; time = 7 milliseconds; 17341857 sends/sec.
n2 = 26; time = 12 milliseconds; 16368167 sends/sec.
n2 = 27; time = 20 milliseconds; 15890550 sends/sec.
n2 = 28; time = 34 milliseconds; 15124382 sends/sec.
n2 = 29; time = 49 milliseconds; 16980408 sends/sec.
n2 = 30; time = 82 milliseconds; 16417915 sends/sec.
n2 = 31; time = 134 milliseconds; 16256037 sends/sec.
n2 = 32; time = 214 milliseconds; 16469991 sends/sec.
n2 = 33; time = 362 milliseconds; 15753831 sends/sec.
n2 = 34; time = 603 milliseconds; 15302595 sends/sec.


As you can see, the pure Javascript is much faster.

I don't know much about the underlying mechanics of Amber (does anyone
have pointers to an overview of how Amber works?).  But I was
surprised that a method that consists of a big chunk of Javascript is
so much slower than the pure Javascript version.   I expected that
there would be a little call overhead, but the Javascript should then
run at nearly full speed.   I seems to me that the Javascript should
not even be measuring the overhead, since all of the calculations and
printing results are all done inside the Javascript code.

As a final update before posting this message, I decided to save the
code to a package, update my index.html with the package reference,
and test again by reloading the Amber page. (vs. just typing the code
into Amber and immediately running the test in a workspace). Here are
the results:

n1 = 2; time = 4 milliseconds; 250000000 operations/sec.
n1 = 4; time = 1 milliseconds; 2000000000 operations/sec.
n1 = 8; time = 3 milliseconds; 1333333333 operations/sec.
n1 = 16; time = 5 milliseconds; 1600000000 operations/sec.
n1 = 32; time = 10 milliseconds; 1600000000 operations/sec.
n1 = 64; time = 21 milliseconds; 1523809524 operations/sec.
n1 = 128; time = 41 milliseconds; 1560975610 operations/sec.
n1 = 256; time = 96 milliseconds; 1333333333 operations/sec.
n1 = 512; time = 170 milliseconds; 1505882353 operations/sec.
n1 = 1024; time = 347 milliseconds; 1475504323 operations/sec.
n1 = 2048; time = 716 milliseconds; 1430167598 operations/sec.

n2 = 24; time = 5 milliseconds; 15005000 sends/sec.
n2 = 25; time = 8 milliseconds; 15174125 sends/sec.
n2 = 26; time = 12 milliseconds; 16368167 sends/sec.
n2 = 27; time = 18 milliseconds; 17656167 sends/sec.
n2 = 28; time = 30 milliseconds; 17140967 sends/sec.
n2 = 29; time = 50 milliseconds; 16640800 sends/sec.
n2 = 30; time = 81 milliseconds; 16620605 sends/sec.
n2 = 31; time = 131 milliseconds; 16628313 sends/sec.
n2 = 32; time = 213 milliseconds; 16547315 sends/sec.
n2 = 33; time = 345 milliseconds; 16530107 sends/sec.
n2 = 34; time = 602 milliseconds; 15328015 sends/sec.

These numbers are much better than the code that was entered live in
Amber.  Maybe the Javascript JIT does not optimize dynamically loaded
code?   But, the sends/sec measurements are still low compared to the
pure Javascript benchmarks.

Does anyone have any ideas about what is going on here?

(BTW these tests are using IE 9 on Windows 7).

Thanks!

Jerry
Reply | Threaded
Open this post in threaded view
|

Re: Javascript benchmarks in Google Chrome on Android 4.0

jdbell
Very impressive!

I tried the benchmark on my PC under Chrome, and ended up with about
4x the performance of my original test.  So I guess Chrome's
Javascript engine is quite a bit better than IE's!

Did you try executing the benchmark from within Amber?  I would be
interested to know if you have the same expreience with "dynamic" code
speed vs. code loaded from a package.  I duplicated my experiment
under Chrome:   After loading my simple test package and running it in
a workspace, my results were very close to running the javascript
benchmark directly.   I then renamed my test method, and ran the
renamed version in a workspace - resulting in about 1/4 of the speed.

-Jerry
Reply | Threaded
Open this post in threaded view
|

Re: Javascript benchmarks in Google Chrome on Android 4.0

Hannes Hirzel
=========
Firefox 9
http://www.weather-dimensions.com/Dan/JavaScriptBenchmark.html
=========
JavaScript Performance Benchmark

n1 = 2; time = 2 milliseconds; 500000000 operations/sec.
n1 = 4; time = 2 milliseconds; 1000000000 operations/sec.
n1 = 8; time = 4 milliseconds; 1000000000 operations/sec.
n1 = 16; time = 8 milliseconds; 1000000000 operations/sec.
n1 = 32; time = 13 milliseconds; 1230769231 operations/sec.
n1 = 64; time = 16 milliseconds; 2000000000 operations/sec.
n1 = 128; time = 32 milliseconds; 2000000000 operations/sec.
n1 = 256; time = 64 milliseconds; 2000000000 operations/sec.
n1 = 512; time = 131 milliseconds; 1954198473 operations/sec.
n1 = 1024; time = 277 milliseconds; 1848375451 operations/sec.
n1 = 2048; time = 544 milliseconds; 1882352941 operations/sec.

n2 = 24; time = 2 milliseconds; 37512500 sends/sec.
n2 = 25; time = 3 milliseconds; 40464333 sends/sec.
n2 = 26; time = 5 milliseconds; 39283600 sends/sec.
n2 = 27; time = 8 milliseconds; 39726375 sends/sec.
n2 = 28; time = 13 milliseconds; 39556077 sends/sec.
n2 = 29; time = 21 milliseconds; 39620952 sends/sec.
n2 = 30; time = 34 milliseconds; 39596147 sends/sec.
n2 = 31; time = 54 milliseconds; 40339056 sends/sec.
n2 = 32; time = 88 milliseconds; 40052023 sends/sec.
n2 = 33; time = 143 milliseconds; 39880329 sends/sec.
n2 = 34; time = 229 milliseconds; 40294607 sends/sec.
n2 = 35; time = 371 milliseconds; 40243536 sends/sec.
n2 = 36; time = 599 milliseconds; 40330245 sends/sec.

--------------------------------
Firefox 10
--------------------------------

Firefox 10 (came out in January)
n1 = 2; time = 3 milliseconds; 333333333 operations/sec.
n1 = 4; time = 2 milliseconds; 1000000000 operations/sec.
n1 = 8; time = 4 milliseconds; 1000000000 operations/sec.
n1 = 16; time = 7 milliseconds; 1142857143 operations/sec.
n1 = 32; time = 15 milliseconds; 1066666667 operations/sec.
n1 = 64; time = 30 milliseconds; 1066666667 operations/sec.
n1 = 128; time = 60 milliseconds; 1066666667 operations/sec.
n1 = 256; time = 64 milliseconds; 2000000000 operations/sec.
n1 = 512; time = 128 milliseconds; 2000000000 operations/sec.
n1 = 1024; time = 287 milliseconds; 1783972125 operations/sec.
n1 = 2048; time = 553 milliseconds; 1851717902 operations/sec.

n2 = 24; time = 4 milliseconds; 18756250 sends/sec.
n2 = 25; time = 3 milliseconds; 40464333 sends/sec.
n2 = 26; time = 5 milliseconds; 39283600 sends/sec.
n2 = 27; time = 7 milliseconds; 45401571 sends/sec.
n2 = 28; time = 13 milliseconds; 39556077 sends/sec.
n2 = 29; time = 19 milliseconds; 43791579 sends/sec.
n2 = 30; time = 32 milliseconds; 42070906 sends/sec.
n2 = 31; time = 51 milliseconds; 42711941 sends/sec.
n2 = 32; time = 83 milliseconds; 42464795 sends/sec.
n2 = 33; time = 133 milliseconds; 42878850 sends/sec.
n2 = 34; time = 217 milliseconds; 42522880 sends/sec.
n2 = 35; time = 348 milliseconds; 42903310 sends/sec.
n2 = 36; time = 563 milliseconds; 42909089 sends/sec.


No big difference in this test between Firefox 9 and 10 on just the benchmark
http://www.weather-dimensions.com/Dan/JavaScriptBenchmark.html

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
I wanted to evaluate the code from within Amber

I put the code into
<

>
brackets

and exchanged "  by ' and change <BR> to just BR.

I seemed to compile but no output.

Could you please post your version of the JavaScript benchmark code
which works in Amber?

Hannes


P.S.
This is what I used

<
        // A simple prime-finder dominated by arithmetic, logic and subscripting
        // (Originally due to Trygve Reenskaug)
        var opBenchmark = function (nReps) {
                var size = 8190; var count;
                for(var iter= 0; iter<nReps; iter++) {
                        count = 0;
                        flags = new Array(size);
                        for(var i=0; i<size; i++) flags[i]= true;
                        for(var i=1; i<=size; i++) {
                                if(flags[i-1]) {
                                        var prime = i+1;
                                        var k = i + prime;
                                        while(k <= size) {
                                                flags[k-1] = false;
                                                k = k + prime; }
                                        count = count + 1; }}}
                return count; }

        var msDiff = function (t1, t0) { return ((t1.getSeconds()*1000) +
t1.getMilliseconds())
                                                                        - ((t0.getSeconds()*1000) + t0.getMilliseconds()); }

        // A user-defined object with a user-defined message (the Fibonacci function)
        function Fibber(x) {this.x= x;}
        Fibber.prototype.fib= function(i) {
                if(i<2) return 1;
                return this.fib(i-1) + this.fib(i-2); }

        // Now we run them and report results
        var tinyBenchmarks = function () {
                var t0, t1, n1, n2, result, time;
                // First the integer ops benchmark...
                n1= 1;
                do {n1= n1*2;
                        t0= new Date();
                        result= opBenchmark(n1);
                        t1= new Date();
                        var time1= msDiff(t1, t0);
                        document.write("n1 = " + n1 + "; time = " + time1 + " milliseconds; "
                                + ((n1 * 500000 * 1000) / time1).toFixed(0) + " operations/sec. BR"); }
                while (time1 < 500);
                document.write('........................................................');
                // Then the message send benchmark
                n2= 23;
                do {n2= n2+1;
                        t0= new Date();
                        result= (new Fibber(1)).fib(n2);
                        t1= new Date();
                        var time2= msDiff(t1, t0);
                        document.write('n2 = ' + n2 + '; time = ' + time2 + ' milliseconds; '
                                + (((result * 1000) / time2)).toFixed(0) + ' sends/sec. BR'); }
                while (time2 < 500);
        }

        tinyBenchmarks();


>




On 2/13/12, Jerry Bell <[hidden email]> wrote:

> Very impressive!
>
> I tried the benchmark on my PC under Chrome, and ended up with about
> 4x the performance of my original test.  So I guess Chrome's
> Javascript engine is quite a bit better than IE's!
>
> Did you try executing the benchmark from within Amber?  I would be
> interested to know if you have the same expreience with "dynamic" code
> speed vs. code loaded from a package.  I duplicated my experiment
> under Chrome:   After loading my simple test package and running it in
> a workspace, my results were very close to running the javascript
> benchmark directly.   I then renamed my test method, and ran the
> renamed version in a workspace - resulting in about 1/4 of the speed.
>
> -Jerry
>