Skip to content

Added performance testing against JBuilder#43

Merged
fterrazzoni merged 1 commit into
masterfrom
jbuilder-comparison-benchmark
Sep 3, 2017
Merged

Added performance testing against JBuilder#43
fterrazzoni merged 1 commit into
masterfrom
jbuilder-comparison-benchmark

Conversation

@fterrazzoni
Copy link
Copy Markdown
Contributor

@fterrazzoni fterrazzoni commented Sep 3, 2017

Results:

                                     user     system      total        real
Jbuilder                         0.560000   0.000000   0.560000 (  0.561676)
BABL                             0.440000   0.000000   0.440000 (  0.445175)
Precompiled BABL                 0.380000   0.000000   0.380000 (  0.375273)

When the template is pre-compiled, BABL is ~ 30% faster than JBuilder. This is very encouraging, given that code generation hasn't been merged yet.

😎😎😎

BABL template :

author = object(:name, :birthyear, :job)

each.object(
    :body, :title,
    author: _.(author),
    date: _.nav(&:iso8601),
    references: _.each.object(:name, :url),
    comments: _.each.object(
        :email, :body,
        author: _.(author),
        date: _.nav(:iso8601)
    )
)

JBuilder template:

json.array! data do |article|
    json.author(article.author, :name, :birthyear, :job)
    json.title article.title
    json.body article.body
    json.date article.date.iso8601
    json.references article.references do |reference|
        json.name reference.name
        json.url reference.url
    end
    json.comments article.comments do |comment|
        json.author(comment.author, :name, :birthyear, :job)
        json.email comment.email
        json.body comment.body
        json.date comment.date.iso8601
    end
end

@fterrazzoni fterrazzoni merged commit d6c1b4c into master Sep 3, 2017
@fterrazzoni fterrazzoni deleted the jbuilder-comparison-benchmark branch September 3, 2017 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant