[
https://issues.apache.org/jira/browse/COUCHDB-681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841265#action_12841265
]
Filipe Manana commented on COUCHDB-681:
---------------------------------------
Even just for 100 Kb of data, the difference is noticeable:
1> Data = crypto:rand_bytes(100 * 1024).
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,161,136,...>>
2>
2> timer:tc(couch_util, encodeBase64, [Data]).
{41470,
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Z"...>>}
3> timer:tc(couch_util, encodeBase64, [Data]).
{41396,
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Z"...>>}
4> timer:tc(couch_util, encodeBase64, [Data]).
{41868,
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Z"...>>}
5>
5>
5> timer:tc(base64, encode, [Data]).
{12503,
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Z"...>>}
6> timer:tc(base64, encode, [Data]).
{13310,
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Z"...>>}
7> timer:tc(base64, encode, [Data]).
{12821,
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Z"...>>}
8>
8> Data64 = base64:encode(Data).
<<"guk++G9ezaPJZXS+oVDVcRwQOykr/qWtGkF2oYh017ceq7+1HSif7yyTvs2hQaDixjLRYmr+dcnQgC6omSRlUacBrB2dJevZLhPjmlJ3k95Zzxx+1Tf+"...>>
9>
9> timer:tc(couch_util, decodeBase64, [Data64]).
{48213,
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,...>>}
10> timer:tc(couch_util, decodeBase64, [Data64]).
{48292,
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,...>>}
11> timer:tc(couch_util, decodeBase64, [Data64]).
{51423,
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,...>>}
12>
12>
12> timer:tc(base64, decode, [Data64]).
{15965,
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,...>>}
13> timer:tc(base64, decode, [Data64]).
{16030,
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,...>>}
14> timer:tc(base64, decode, [Data64]).
{14201,
<<130,233,62,248,111,94,205,163,201,101,116,190,161,80,
213,113,28,16,59,41,43,254,165,173,26,65,118,...>>}
15>
> couch_util:encodeBase64 vs base64:encode
> ----------------------------------------
>
> Key: COUCHDB-681
> URL: https://issues.apache.org/jira/browse/COUCHDB-681
> Project: CouchDB
> Issue Type: Improvement
> Components: Infrastructure
> Environment: trunk and all other branches
> Reporter: Filipe Manana
> Attachments: base64-trunk.patch
>
>
> Just noticed that OTP's base64:encode is about one order of magnitude faster
> than couch_util:encodeBase64:
> fdman...@core2duo:~/git/couchdb/bin$ ./couchdb -i
> Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:2:2] [rq:2]
> [async-threads:0] [hipe] [kernel-poll:true]
> Eshell V5.7.4 (abort with ^G)
> 1> Apache CouchDB 0.11.0bd318717-git (LogLevel=info) is starting.
> Apache CouchDB has started. Time to relax.
> [info] [<0.37.0>] Apache CouchDB has started on http://127.0.0.1:5984/
> 1> L = crypto:rand_bytes(1024 * 1024).
> <<10,238,241,237,52,176,52,252,99,133,199,63,177,68,141,
> 24,225,251,115,187,34,143,152,253,150,170,9,122,0,...>>
> 2>
> 2> timer:tc(couch_util, encodeBase64, [L]).
> {368052,
>
> <<"Cu7x7TSwNPxjhcc/sUSNGOH7c7sij5j9lqoJegDoP07QyKeuCeMtWD7aXcW0junYH1csNda3F83owKQDw6D8pI+Ep0A231BD2sMEYF0XFkCW"...>>}
> 3> timer:tc(couch_util, encodeBase64, [L]).
> {361919,
>
> <<"Cu7x7TSwNPxjhcc/sUSNGOH7c7sij5j9lqoJegDoP07QyKeuCeMtWD7aXcW0junYH1csNda3F83owKQDw6D8pI+Ep0A231BD2sMEYF0XFkCW"...>>}
> 4> timer:tc(couch_util, encodeBase64, [L]).
> {361141,
>
> <<"Cu7x7TSwNPxjhcc/sUSNGOH7c7sij5j9lqoJegDoP07QyKeuCeMtWD7aXcW0junYH1csNda3F83owKQDw6D8pI+Ep0A231BD2sMEYF0XFkCW"...>>}
> 5>
> 5> timer:tc(base64, encode, [L]).
> {91055,
>
> <<"Cu7x7TSwNPxjhcc/sUSNGOH7c7sij5j9lqoJegDoP07QyKeuCeMtWD7aXcW0junYH1csNda3F83owKQDw6D8pI+Ep0A231BD2sMEYF0XFkCW"...>>}
> 6> timer:tc(base64, encode, [L]).
> {107130,
>
> <<"Cu7x7TSwNPxjhcc/sUSNGOH7c7sij5j9lqoJegDoP07QyKeuCeMtWD7aXcW0junYH1csNda3F83owKQDw6D8pI+Ep0A231BD2sMEYF0XFkCW"...>>}
> 7> timer:tc(base64, encode, [L]).
> {96070,
>
> <<"Cu7x7TSwNPxjhcc/sUSNGOH7c7sij5j9lqoJegDoP07QyKeuCeMtWD7aXcW0junYH1csNda3F83owKQDw6D8pI+Ep0A231BD2sMEYF0XFkCW"...>>}
> Same goes for base64:decode vs couch_util:decodeBase64
> Therefore I supply a patch to do the switch.
> It also allows us to short a little couch_util :)
> I executed all tests, both Etap and JS, and everything is fine with the
> switch.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.