[erlang-questions] NIF vs Erlang Binary

Andy W. Song wsongcn@REDACTED
Fri Jul 22 11:45:52 CEST 2011


Hi,

I'm trying to write an Erlang WebSocket client and server against the latest
spec. It requires message masking, which simply xor the whole message using
a 4 bytes key.
Here<http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10#page-20>
is
the reference.

I did some unit test on my code and felt that it's slow (it can process
about  24M byte/s) on a virtual machine. HiPE can double the performance but
still not quite enough. So I wrote an NIF to handle this. The speed is about
10~15x faster. Not only that, I feel that the C code is easier to write.
Maybe it's due to my inexperienced with Erlang yet.

Here is the Erlang <https://gist.github.com/1099160>and NIF
<https://gist.github.com/1099154>code, FYI.

Thanks
Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110722/df770fbd/attachment.htm>


More information about the erlang-questions mailing list