Re: URL classes in node and Scala-JS

On 9 Jul 2014, at 16:08, henry.story@bblfish.net wrote:

> Hi all,
> 
> 	I have been working on comparing the node URL library and the akka Scala Uri library
> after porting it to Scala-JS.
> 
>   https://github.com/bblfish/node.scalajs
>   https://github.com/bblfish/akka.http.model.Uri
> 
> The current results are that paring a 9.1MB file of URLs
> 
>   	• 37 seconds to parse using Akka's Uri class ported to ScalaJS in Chrome 36.0.1985.97 beta
> 	• 4.226 seconds using the node.js Uri library in Chrome 36...

wrapped in scalajs.

> 	• 4.4 seconds when running node's Url class in node.js  itself 
> 	• 1.453 seconds to parse in the pure scala command line in the JVM
> 
> This suggests that parsing and canonicalisation of URLs should be done on the server, which should as much as possible send zipped and canonicalised n-triples files to the client. The client should then do as little as possible URI analysis - perhaps not more than removing #fragments. The client should stick as much as possible to simple string comparison.
> 
> If others want to verify the tests please do. I may very well have made some mistakes, as I am new to JS. 
> 
> Note that the Uri library in ScalaJS is only 278 bytes or so long uncompressed!
> 
> -rw-r--r--  1 hjs  staff   278B  7 Jul 11:03 http-model-uri-opt.js

Euh. Of course that was too small to be true :-D

-rw-r--r--  1 hjs  staff   609K  9 Jul 17:38 akka-urijs-test-opt.js

That is what is left after compressing the code that is built on a parser called parboiled,
a powerful library called shapeless, and the scala libraries used by the akka code. 
So any code that one writes will probably never be much bigger than that.
Note also that this is uncompressed. It compresses down to 

-rw-r--r--  1 hjs  staff   128440  9 Jul 17:38 akka-urijs-test-opt.js.gz


> 
> The scalajs team have been optimising bytecode size until now and will be starting to optimise speed next. :-)
> 
> Henry
> 
> Social Web Architect
> http://bblfish.net/
> 

Social Web Architect
http://bblfish.net/

Received on Wednesday, 9 July 2014 15:57:24 UTC