jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

Speedup javascript_include_tag. #350

Closed francois2metz closed 9 years ago

francois2metz commented 9 years ago

Appending ?body=1 to all assets make javascript_include_tag very slow.

So only append it to instrumented file and let sprockets to his job for others files.

In our app, performance improvements with this patch are quite impressive (527 JavaScript files so far)

I instrumented _boot.html.erb:

<% puts Benchmark.measure { %>
<%= javascript_include_tag *@suite.spec_assets %>
<% } %>
<script type="text/javascript">
  Teaspoon.onWindowLoad(Teaspoon.execute);
</script>

Without the patch: 12.500000 0.500000 13.000000 ( 13.000034) With the patch: 3.140000 0.120000 3.260000 ( 3.256158)

mikepack commented 9 years ago

If you're running Teaspoon >= 0.9, you can use the expand_assets suite configuration to speed things up. The downside is it makes code harder to debug as the stack traces all point to one monolithic file.

https://github.com/modeset/teaspoon/wiki/Teaspoon-Configuration#suite-configuration-directives

francois2metz commented 9 years ago

Why not speed up thinks for users that don't want to use expand_assets? Any reasons to append body=1 by default? Sprockets will do for you later.

mikepack commented 9 years ago

Because Teaspoon runs in the development Rails environment, and we want to provide a consistent experience regardless of whether the host app's config.assets.debug is set to true or false.